Wraith All American 27257 Posts user info edit post |
I am a complete n00b to MATLAB but I need a bit of help with plotting some data sets. I have four individual m-files that I have written code into, each one creates a plot when it is run. How can I "superimpose" the plots on top of each other so that I can read them all from the same graph? Is there a way I can import a figure on top of an already existing one? 6/13/2006 5:50:57 PM |
joe17669 All American 22728 Posts user info edit post |
you can use the 'hold' function. so if you have a certain figure, you can say 'hold on' and then put multiple plots on there. when you're done, you can do 'hold off'
Quote : | "Is there a way I can import a figure on top of an already existing one?" |
I'm not going to tell you how to manage your matlab plots, but Ive found it to be a good habit of instead of just using 'figure' to create a new plot window, to actually number them in my scripts so that I can go back and add stuff to already-existing figure windows and easily know which figure number I need to use. So I would do stuff like 'figure(1)', 'figure(3)', etc and execute my plots. When I need to go back to figure 1 and add a new plot, I would go back to 'figure(1)' and do 'hold on' before I execute the plot function. that way it will add it to the existing plot instead of overwriting it.
Oh, so many words. Sorry, here's some pseudocode to more clearly make my point
figure(1) plot(y,x)
figure(2) plot(y2,x2)
%% run some more code, need to add something to figure 1 figure(1) hold on plot(y3,x3) hold off ]6/13/2006 5:53:13 PM |
Specter All American 6575 Posts user info edit post |
is essentially what you need
[Edited on June 13, 2006 at 7:57 PM. Reason : ]6/13/2006 7:55:34 PM |
joe17669 All American 22728 Posts user info edit post |
^ i have problems with using too many words 6/14/2006 12:51:06 AM |
Wraith All American 27257 Posts user info edit post |
Awesome, I got it work, thanks guys. Is there a way I can add a grid to just the Y-axis? I know that by putting "grid on", it will add major grid lines to both the X and Y-axes. I can turn off the X-axis grid manually by double clicking on the plot but is there a way I can do it in the code?
[Edited on June 14, 2006 at 9:28 AM. Reason : ] 6/14/2006 9:20:35 AM |
jatncstate All American 724 Posts user info edit post |
help (insert function here) is what I always refer to.... so type "help plot" that should give you all the info you need in changing colors, chaning lines to x's and o's and dashes etc. 6/14/2006 6:35:27 PM |