MATLAB Answers

Ano
0

Legend of Many curves on one graph?!

Asked by Ano
on 12 Jun 2017
Latest activity Answered by KSSV
on 12 Jun 2017
Accepted Answer by KSSV
Hello, I would like to have a legend that is on a for-loop so for each entry I would like to have a name of my data , how can I do it ? I have tried the following line but it doesn't work!
for i=1:5
load all my file .*mat
do some calculations
plot(data)
legend (num2str(i))
hold on
end

  0 Comments

Sign in to comment.

Tags

1 Answer

Answer by KSSV
on 12 Jun 2017
 Accepted Answer

N = 5 ;
str = cell(N,1) ;
for i=1:N
% load all my file .*mat
% do some calculations
plot(rand(10,1))
str{i} = num2str(i) ;
hold on
end
legend(str)

  0 Comments

Sign in to comment.