I am trying to plot different curves in gui, but i dont know how to add legend to it.

1 view (last 30 days)
My plots depend on a single variable 's' which i take from the user. I get the plot but am unable to get all the legends for different plots that the user plot for different 's' values. This is the plotting part of the code. where 'i' is a global parameter which increments with each new value of 's'.
p(i)= plot(x,y,'linewidth',2,'Color',clr(i));
hold on
grid on
title('Rotor Voltage Limit for Various Slip values')
xlabel('P');
ylabel('Q');
Legend{i}=strcat('S=', num2str(s));
for l=1:i
legend([p(1:l)],Legend{1:l})
end
  2 Comments

Sign in to comment.

Accepted Answer

Rik
Rik on 1 Apr 2017
Try if this works: replace this
for l=1:i
legend([p(1:l)],Legend{1:l})
end
with this
legend(p(1:i),Legend(1:i))
  18 Comments
Rik
Rik on 5 Apr 2017
You're welcome. It is often these little typos that make for the most inexplicable problems.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!