My matlab plot is blank when I plot

1 回表示 (過去 30 日間)
Henry Wolf
Henry Wolf 2019 年 3 月 12 日
編集済み: David Goodmanson 2019 年 3 月 12 日
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)')

採用された回答

David Goodmanson
David Goodmanson 2019 年 3 月 12 日
編集済み: David Goodmanson 2019 年 3 月 12 日
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 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by