I have the below code. I cannot figure out how to obtain the real and imaginary parts of the symbolic polynomial (I have already solved the complete problem in standard Matlab, trying to learn the Symbolic Toolbox). My code is:
polynomial = [1 10 45 105 105];
p = poly2sym(polynomial, s)
pw = subs(p, 1*j*w)
real_pw = simplify( rewrite(real(pw), 'exp') )
imag_pw = simplify( rewrite(imag(pw), 'exp') )
sq_real = conv(real_pw, real_pw);
sq_imag = conv(imag_pw, imag_pw);
sq_denom = sq_real + sq_imag;
The above code gives me:
real_pw =
10*imag(w^3) - 45*real(w^2) + real(w^4) - 105*imag(w) + 105
imag_pw =
imag(w^4) - 45*imag(w^2) - 10*real(w^3) + 105*real(w)
Instead, I am expecting something like (obtained from my working plain Matlab code):
real_poly = 1 0 -45 0 105
imag_poly = 0 -10 0 105 0
Any help you can provide is appreciated!
0 Comments
Sign in to comment.