We have moved to @ Placement Papers Hub !! Visit our new website here for more..

MATLAB Adding New Plots to Existing Plot


MATLAB:Adding New Plots to Existing Plot


>> x=linspace(0,5);                                   
>> y=sin(x);
>> plot(x,y);
>> hold on
>> x1=0:0.5:8;
>> y1=sin(x1);
>> plot(x1,y1);














You can plot more than one function on the same figure. Let's say you want to plot a sine wave and cosine wave on the same set of axes, using a different color and point marker for each. The following m-file could be used to do this:

» x = linspace(0,2*pi,50);               
» y = sin(x);
» z = cos(x);
» plot(x,y,'r', x,z,'gx')