Unable to convert expression into double array.

2 visualizaciones (últimos 30 días)
Pablo Álvarez García
Pablo Álvarez García el 12 de Feb. de 2022
Respondida: Prachi Kulkarni el 15 de Feb. de 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)')

Respuesta aceptada

Prachi Kulkarni
Prachi Kulkarni el 15 de Feb. de 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)')

Más respuestas (0)

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!