Matlab Graph

Solved
Pallas -  
Fee Fay Posted messages 646 Registration date   Status Membre -
Hello,

I need to plot a function using Matlab that represents the path of a light ray based on several formulas involving temperature, height, the angle at which the ray arrives, etc.
I have managed to create this function and I get a graph that is (in my opinion) correct.
Now I need to display several functions on the same graph by varying the initial angle (between -1° and 0.1°).

I tried using the command
For i0=-1:0.1:0.1;
function(...);
plot(x,z);
end

But this only gives me the function for the last angle, that is, when i0 is equal to 0.1.

If someone could advise/guide me, it would be really kind of them.
Configuration: Windows XP Firefox 3.0.7

11 réponses

Fee Fay Posted messages 646 Registration date   Status Membre 377
 
Good evening my friend!

You just need to add the hold on command before your loop.
If you plan to relaunch your program or plot other curves on another figure, use the hold off command beforehand; otherwise, you will have the new curves on top of those from the figure produced by the loop.
Finally, to summarize, do something like this:
hold on; for i0=-1:0.1:0.1 function(...); plot(x,z); end hold off;
I wish you a very good evening!
--
All the animals shouted very loudly
That he was the most beautiful toad when he played the banjo.
10