My matlab plot is blank when I plot

1 view (last 30 days)
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)')

Accepted Answer

David Goodmanson
David Goodmanson on 12 Mar 2019
Edited: David Goodmanson on 12 Mar 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.

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!