Azzera filtri
Azzera filtri

Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

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

1 visualizzazione (ultimi 30 giorni)
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 Commento
dpb
dpb il 26 Dic 2014
Modificato: dpb il 27 Dic 2014
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...

Risposte (0)

Questa domanda è chiusa.

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by