legend plotting help with for loop
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
hi everyone, i have the code below which works fine and plots the data i need, however the legend note only states the final loop input and shows it next to the line colour red, is there any way i can have the legend to show the 3 different line types i need thanks kyle
for i = 1 : k(1)
%loads internal forces for plotting
file_name = sprintf('internalforce_%d',i);
variable = load(file_name,'int_force');
%loads deflection for plotting
filetwo_name = sprintf('data_%d',i);
variabletwo = load(filetwo_name,'deflection');
%create a colour array for use in altering plot colours
mark = {'*-r','o-g','^-b','*-k','*-c','*-r'};
%plots the Force displacment graphs on one plot
plot(-variabletwo.deflection,-variable.int_force,mark{i});legend(filetwo_name)
%sets titles and axis for graph
xlabel(['OX axis ' lengthunits]);ylabel(['OY axis ' axialunits]);
title('Force Displacment Graph '); grid on
end
0 Kommentare
Antworten (1)
Paulo Silva
am 9 Mai 2011
Something similar to this:
hold on
mark = {'*-r','o-g','^-b','*-k','*-c','*-r'};
for i = 1 : 6
%loads internal forces for plotting
%file_name = sprintf('internalforce_%d',i);
%variable = load(file_name,'int_force');
%loads deflection for plotting
%filetwo_name = sprintf('data_%d',i);
%variabletwo = load(filetwo_name,'deflection');
%create a colour array for use in altering plot colours
%plots the Force displacment graphs on one plot
p(i)=plot(i,i,mark{i})%legend(filetwo_name)
%sets titles and axis for graph
%xlabel(['OX axis ' lengthunits]);ylabel(['OY axis ' axialunits]);
%title('Force Displacment Graph '); grid on
end
legend(p,mark)
0 Kommentare
Siehe auch
Kategorien
Mehr zu Legend finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!