Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

In a graph in a 'for' loop, how to add a legend with a variable/parameter in it?

Status
Not open for further replies.

OmegaForce

Industrial
Mar 9, 2015
3
0
0
FR
Hello.

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.
 
Replies continue below

Recommended for you

Status
Not open for further replies.
Back
Top