フィルターのクリア

Legend does not recognize semilogx plot

7 ビュー (過去 30 日間)
Felix Tieleman
Felix Tieleman 2022 年 4 月 4 日
回答済み: Star Strider 2022 年 4 月 4 日
The legend I plot does not recognize all my plots. I have 1 bode plot (only the magnitude) and 2 semilogx plots. The first two semilogx plots do not seem to appear in the legend. Logically, Matlab also tells me that it is ignoring 'extra' legend entries.
This is my relevant code
figure(5),clf(5)
p = bodeoptions('cstprefs');
p.FreqUnits = 'rad/s';
p.PhaseVisible = 'off';
hold on
semilogx(w,spec_y(1:length(f)),'r')
semilogx(w,spec_y0(1:length(f)),'b')
bodeplot(G0,p,'g');
legend('y','y0','Exact')
grid on
%set(gca, 'XScale', 'log');
xlabel('w (rad/s)')
ylabel('|Mag| (dB)')
This is the output, showing only the first legend entry for the 'bodeplot(G0,p,'g')' plot.

採用された回答

Star Strider
Star Strider 2022 年 4 月 4 日
I have no idea what the other values are that you are plotting on the bodeplot axes. Apparently, the only legend entries bodeplot permits are the systems it plots.
It might be easier to get the data from bodeplot and plot everything on ‘ordinary’ axes.
This outlines how to get those data from bodeplot
sys = tf([1 0 0],[1 1 1 1 1])
sys = s^2 ----------------------- s^4 + s^3 + s^2 + s + 1 Continuous-time transfer function.
h = bodeplot(sys)
h = resppack.bodeplot
Frq = h.Responses.Data.Frequency
Frq = 72×1
0.0000 0.0000 0.0000 0.0000 0.0000 0.0020 0.0200 0.0234 0.0273 0.0320
Mag = h.Responses.Data.Magnitude
Mag = 72×1
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0004 0.0005 0.0007 0.0010
Phs = h.Responses.Data.Phase
Phs = 72×1
-3.1416 -3.1416 -3.1416 -3.1416 -3.1416 -3.1436 -3.1616 -3.1650 -3.1689 -3.1736
.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLegend についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by