HOw to add legends to plot after each iteraion in for loop?
2 views (last 30 days)
Show older comments
for i =2:1:8;
figure(1)
plot(T,Results_Geregelt_mu_Fahrbahn1_Sturzwinkel_Changed{i,1},'LineWidth',2); grid on; hold all;
title('Zurueckgelegte Strecke');
xlabel('t [s]'); ylabel('sx [m]');
axis([0 tende 10 50])
set(gca,'XTick',0:5:tende)
set(gca,'YTick',10:10:50)
end
Legend=cell(7,1);
for iter=1:7
Legend{iter}=strcat('Camber Angle= ', num2str(iter));
end
legend(Legend)
hold off;
instead of 'num2str(iter)' i want to add angles stariong from 45 till 15 deg (45,40,35,30.....15)
0 Comments
Answers (1)
Star Strider
on 3 Nov 2015
The cell array may cause more problems than it solves. I would do this:
CAdeg = fix(45:-5:15);
for k1 = 1:length(CAdeg)
Legend(k1,:) = sprintf('Camber Angle = %.0f\n', CAdeg(k1));
end
figure(1)
plot(rand,rand,'p', rand,rand,'p', rand,rand,'p', rand,rand,'p', rand,rand,'p', rand,rand,'p', rand,rand,'p')
legend(Legend)
0 Comments
See Also
Categories
Find more on Legend in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!