フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Legend doesn't work with subplot in 2014b but same code works in 2010a

1 回表示 (過去 30 日間)
Srinath
Srinath 2014 年 12 月 26 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
I have this code that works in 2010a
subplot(2,2,1)
plot(tstore,xstore(:,1))
hold on
plot(t,TAS_model-x0(1),'r')
title('TAS comparison')
xlabel('time-secs')
ylabel('Vel-m/s')
legend('Linear model','Non linear model')
subplot(2,2,2)
plot(tstore,xstore(:,2))
hold on
plot(t,alpha_model-x0(2),'r')
title('Alpha comparison')
xlabel('time-secs')
ylabel('Alpha-Rad')
All variables exist in workspace and plots turn out fine in 2010a. In 2014b i get an error from the legend function that it has a wrong number of inputs.
Any ideas why? I wish the developers had kept backward compatibility in mind.
  1 件のコメント
dpb
dpb 2014 年 12 月 26 日
編集済み: dpb 2014 年 12 月 27 日
I hear ya' on the compatibility issues w/ Matlab...'tis a pain indeed.
However, nothing in the current doc indicates that the above shouldn't work; the only documented change is that legend now returns one of the high-falutin' new "objects" instead of an axes handle, but no mention of function inputs changing.
While it shouldn't be necessary, just for debugging try
hL=plot(tstore,xstore(:,1));
hold on
hL=[hL; plot(t,TAS_model-x0(1),'r')];
legend(hL,'Linear model','Non linear model')
and see if it associates the strings correctly with the line handles.
Either way, I'd submit the original code to official support at www.mathworks.com as a bug in the new graphics engine implementation.
ADDENDUM
Of course, try
clear legend
which legend
to ensure you haven't inadvertently created an aliased version...

回答 (0 件)

この質問は閉じられています。

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by