% Example 4.4a (Physics 330) clear; close all; %********************************************************* % Here's the first way -- just ask for multiple plots on the % same plot line %********************************************************* x=0:.01:20; y=sin(x); % load y with sin(x) y2=cos(x); % load y2 with cos(x), the second function % plot both plot(x,y,'r-',x,y2,'b-') title('First way') %********************************************************* % Here's the second way -- after the first plot tell Matlab % to hold the plot so you can put a second one with it %********************************************************* figure plot(x,y,'r-') hold on plot(x,y2,'b-') title('Second way') hold off