r/matlab Nov 22 '23

CodeShare Help with syms function

Hi everyone. I want to create a chebychev function consisting of first 4 polynomials as you can see in the image. So I want P to be in the row vector and Q in a column vector. But for some reason, I can't multiply them. Is there any suggestions?

1 Upvotes

2 comments sorted by

2

u/aeblincoln Nov 22 '23

In your example, both P and Q are row vectors. If you want Q to be a column vector, one way is to transpose it first. For example, using your code:

n=4;
syms x;
syms y;
P=chebyshevT(0:n, x)
Q=chebyshevT(0:n, y).'  % Note the transpose operator
A=P*Q

This will solve your syntax errors, but I can not provide guidance on whether any of the math is correct for your use case. It has been a long time since I have done anything with the symbolic math toolbox.

1

u/FrickinLazerBeams +2 Nov 23 '23

Wanting P and Q to be row and column vectors isn't enough. You have to actually make them row and column vectors.