From the context of the code, it appear that w is a real number. Assuming it being so will help:
>> syms s
syms w real
polynomial = [1 10 45 105 105];
p = poly2sym(polynomial, s);
pw = subs(p, 1j*w);
real_pw = simplify( rewrite(real(pw), 'exp') )
imag_pw = simplify( rewrite(imag(pw), 'exp') )
real_pw = real(pw)
imag_pw = imag(pw)
real_pw =
w^4 - 45*w^2 + 105
imag_pw =
- 10*w^3 + 105*w
real_pw =
w^4 - 45*w^2 + 105
imag_pw =
- 10*w^3 + 105*w
I don't believe that conv is supported for symbolic polynomials (version 2019a)
>> conv(real_pw,real_pw)
Error using conv2
Invalid data type. First and second arguments must be numeric or logical.
Error in conv (line 43)
c = conv2(a(:),b(:),shape);
But conv is the same as polynomial multiplication, so maybe this is what you want:
>> sq_real = real_pw*real_pw
sq_real =
(w^4 - 45*w^2 + 105)^2
>> sq_imag = imag_pw*imag_pw
sq_imag =
(- 10*w^3 + 105*w)^2
>> sq_denom = sq_real + sq_imag
sq_denom =
(- 10*w^3 + 105*w)^2 + (w^4 - 45*w^2 + 105)^2
>> expand(sq_denom)
ans =
w^8 + 10*w^6 + 135*w^4 + 1575*w^2 + 11025
Best Answer