My matlab plot is blank when I plot
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Henry Wolf
am 12 Mär. 2019
Bearbeitet: David Goodmanson
am 12 Mär. 2019
Hello all,
The plot opens up with all the appropriate labels, but the actual line does not show up. I have tried switching the 'w' and 'f' in the function H1 and H2 when I try to plot.
f = -100:0.1:100;
w = 2*pi*f;
H1 = @(s) (s.^2 + 98010.65) / (s.^2 + 52.36*s + 98010.65);
subplot(2,1,1)
plot(f,abs(H1(j*w)),'k')
grid on
%xlabel('2*pi*f')
%ylabel('|H_1(j*2*pi*f)|')
subplot(2,1,2)
plot(f, angle(H1(j*w)))
grid on
%xlabel('2*pi*f')
%ylabel('<H_1(j*2*pi*f)')
0 Kommentare
Akzeptierte Antwort
David Goodmanson
am 12 Mär. 2019
Bearbeitet: David Goodmanson
am 12 Mär. 2019
Hi Henry,
In the definition of H1, use
./ instead of /
so you get term-by-term division. To spot the error, one straighforward thing to do Is define a new variable
z = H1(j*w)
subplot(2,1,1)
plot(f,abs(z),'k')
This puts z into the workspace and allows you to see that it is a scalar, so it will not plot vs. f. That puts you on the hunt for a particular kind of error in H1.
In this situation I did not get there using the debugger. Maybe someone with more expertise than I have with using the debugger on anonymous functions will weigh in on how to do it.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!