Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

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

1 visualización (últimos 30 días)
Srinath
Srinath el 26 de Dic. de 2014
Cerrada: MATLAB Answer Bot el 20 de Ag. de 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 comentario
dpb
dpb el 26 de Dic. de 2014
Editada: dpb el 27 de Dic. de 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...

Respuestas (0)

La pregunta está cerrada.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by