www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/PlottingMultipleDataSetsInOneGraphExample.m

    %% Plotting Multiple Data Sets in One Graph
% Multiple |x-y| pair arguments
% create multiple graphs with a single call to |plot|. MATLAB(R) uses
% a different color for each line. 
%
% For example, these statements plot three related functions of
% |x| :
%%

% Copyright 2015 The MathWorks, Inc.

x = 0:pi/100:2*pi;
y = sin(x);
y2 = sin(x-.25);
y3 = sin(x-.5);
plot(x,y,x,y2,x,y3)
%%
% The |legend| function provides
% an easy way to identify the individual lines:
legend('sin(x)','sin(x-.25)','sin(x-.5)')