Legend does not recognize semilogx plot
7 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
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])
h = bodeplot(sys)
Frq = h.Responses.Data.Frequency
Mag = h.Responses.Data.Magnitude
Phs = h.Responses.Data.Phase
.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Legend 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!