Unable to convert expression into double array.
3 views (last 30 days)
Show older comments
Pablo Álvarez García
on 12 Feb 2022
Answered: Prachi Kulkarni
on 15 Feb 2022
%¿COMO PUEDO DIBUJAR LA PARTE REAL E IMAGINARIA?
syms z w
Gz=z^2/(2*z-5);
Gjw=subs(Gz,z,j*w);
n=0:1:25
figure(1)
mod=abs(Gjw)%grafica la parte real
subplot(2,1,1)
stem(n,mod)
xlabel('frec (Hz)')
ylabel('MÓDULO')
phase=imag(Gjw) %grafica la parte imag
subplot(2,1,2)
stem(n,phase)
xlabel('frec (Hz)')
ylabel('ARGUMENTO')
sgtitle('G(jw)')
0 Comments
Accepted Answer
Prachi Kulkarni
on 15 Feb 2022
Hi,
You haven’t substituted the symbol w with any value. That is why the substitution cannot generate a numeric value. Small changes to your code as shown below can solve the issue.
syms z w % w should not be variable
w = 0:1:25; % assigning some values to w of the same size as n
Gz=z^2/(2*z-5);
Gjw=double(subs(Gz,z,j*w)); % convert sym to double
n=0:1:25
figure(1)
mod=abs(Gjw)%grafica la parte real
subplot(2,1,1)
stem(n,mod)
xlabel('frec (Hz)')
ylabel('MÓDULO')
phase=imag(Gjw) %grafica la parte imag
subplot(2,1,2)
stem(n,phase)
xlabel('frec (Hz)')
ylabel('ARGUMENTO')
sgtitle('G(jw)')
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!