hide legend for certain curves in a Matlab plot
Ältere Kommentare anzeigen
Hello everyone,
I have a little problem here, i plot 8 different curves on a figure but i want to hide the legend for the four last of them since they are only the new step of my simulation, does anybody has an idea to keep the legend for the first of them but hide it for the 4 last ones
TimeStead=max(TimeMeasurStead,TimeRealStead);
TimeStead=max(TimeStead,TimeVelStead);
xx1 = linspace(0,TimeStead(1),1e3).';
xx2 = linspace(0,TimeStead(2),1e3).';
xx3 = linspace(0,TimeStead(3),1e3).';
xx4 = linspace(0,TimeStead(4),1e3).';
tt1 = linspace(TimeStead(1),2000,1e3).';
tt2 = linspace(TimeStead(2),2000,1e3).';
tt3 = linspace(TimeStead(3),2000,1e3).';
tt4 = linspace(TimeStead(4),2000,1e3).';
tstead1=find(Tout1>TimeStead(1));
tstead2=find(Tout2>TimeStead(2));
tstead3=find(Tout3>TimeStead(3));
tstead4=find(Tout4>TimeStead(4));
M=[0,0,0,0];
IC2=[Xout1(tstead1(1),1);Xout1(tstead1(1),2);Xout1(tstead1(1),3);Xout1(tstead1(1),4)];
IC3=[Xout2(tstead2(1),1);Xout2(tstead2(1),2);Xout2(tstead2(1),3);Xout2(tstead2(1),4)];
IC4=[Xout3(tstead3(1),1);Xout3(tstead3(1),2);Xout3(tstead2(1),3);Xout3(tstead2(1),4)];
IC5=[Xout4(tstead4(1),1);Xout4(tstead4(1),2);Xout4(tstead4(1),3);Xout4(tstead4(1),4)];
opts= odeset('RelTol',1e-8,'AbsTol',1e-10);
[~,Xout11] = ode45(@(t,x)mydyn(t,x,M(1)),tt1,IC2,opts);
[~,Xout21] = ode45(@(t,x)mydyn(t,x,M(2)),tt2,IC3,opts);
[~,Xout31] = ode45(@(t,x)mydyn(t,x,M(3)),tt3,IC4,opts);
[~,Xout41] = ode45(@(t,x)mydyn(t,x,M(4)),tt4,IC5,opts);
%data visualisation
figure(8);
plot(tt1,Xout11(:,1),'b','linewidth',2,'displayName','M= 5 Nm');
xlabel('$t$(s)','interpreter','Latex')
ylabel('$T$(K)','interpreter','Latex')
set(gca,'FontSize',11)
hold on;
plot(tt2,Xout21(:,1),'g','linewidth',2,'displayName','M= 15 Nm');
plot(tt3,Xout31(:,1),'r','linewidth',2,'displayName','M= 25 Nm');
plot(tt4,Xout41(:,1),'k','linewidth',2,'displayName','M= 55 Nm');
plot(xx1,Xout1(:,1),'b','linewidth',2,'displayName','');
plot(xx2,Xout2(:,1),'g','linewidth',2,'displayName','');
plot(xx3,Xout3(:,1),'r','linewidth',2,'displayName','');
plot(xx4,Xout4(:,1),'k','linewidth',2,'displayName','');
lgd=legend;
[TimeSteadFinal,TempSteadFinal]=ginput(4);
TimeSteadFinal=TimeSteadFinal-TimeStead;
hold off;
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Legend finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
