Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

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

1 vue (au cours des 30 derniers jours)
Srinath
Srinath le 26 Déc 2014
Clôturé : MATLAB Answer Bot le 20 Août 2021
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 commentaire
dpb
dpb le 26 Déc 2014
Modifié(e) : dpb le 27 Déc 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...

Réponses (0)

Cette question est clôturée.

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by