Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations JAE on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

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
Joined
Mar 9, 2015
Messages
3
Location
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top