In a graph in a 'for' loop, how to add a legend with a variable/parameter in it?
In a graph in a 'for' loop, how to add a legend with a variable/parameter in it?
(OP)
Hello.
Basically this is what I am trying to do:
It should make a succession of graphs, like a mini video, and we should have a legend showing the current value of the parameter 'r'.
But writing legend('r=',r) does not work.
So how do I do it?
Thanks in advance for your answers.
Basically this is what I am trying to do:
CODE
for r=1:0.001:4 y=somefunction(r); plot(x,y) legend('r=',r) pause(0.01) end
It should make a succession of graphs, like a mini video, and we should have a legend showing the current value of the parameter 'r'.
But writing legend('r=',r) does not work.
So how do I do it?
Thanks in advance for your answers.
RE: In a graph in a 'for' loop, how to add a legend with a variable/parameter in it?
is a bit hopeless
legend(num2str(r))
is less so
Cheers
Greg Locock
New here? Try reading these, they might help FAQ731-376: Eng-Tips.com Forum Policies http://eng-tips.com/market.cfm?