Effacer les filtres
Effacer les filtres

Unable to convert expression into double array.

1 vue (au cours des 30 derniers jours)
Pablo Álvarez García
Pablo Álvarez García le 12 Fév 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)')

Réponse acceptée

Prachi Kulkarni
Prachi Kulkarni le 15 Fév 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)')

Plus de réponses (0)

Tags

Community Treasure Hunt

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

Start Hunting!