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

    %% Plot Multiple Lines on Same Figure
% You can plot multiple lines either by passing the inputs as a
% vector or by using |hold on| to successively plot on the same figure.
% If you specify |LineSpec| and Name-Value arguments, they apply to all
% lines. To set options for individual plots, use the function handles returned by |fplot|.
% 
% Divide a figure into two subplots using |subplot|. On the first subplot,
% plot $\sin(x)$ and $\cos(x)$ using vector input. On the second
% subplot, plot $\sin(x)$ and $\cos(x)$ using |hold on|.

syms x
subplot(2,1,1)
fplot([sin(x) cos(x)])
title('Multiple Lines Using Vector Inputs')

subplot(2,1,2)
fplot(sin(x))
hold on
fplot(cos(x))
title('Multiple Lines Using hold on Command')

hold off