Saturday, June 18, 2011

example 3

The above example showing how to put 2 graphs in one figure.

The code is as follow:

function shili03
h0=figure('toolbar','none',...
'position',[200 150 450 350],...
'name','example03');
x=-pi:0.05:pi;
y1=sin(x);
y2=cos(x);
plot(x,y1,...
'-*r',...
x,y2,...
'--og');
grid on
xlabel('X');
ylabel('Y');
title('Plotting 2 graph in one figure');


function shili03%function's name is shili03
h0=figure('toolbar','none',...
'position',[200 150 450 350],...
'name','example03');
x=-pi:0.05:pi;
y1=sin(x);
y2=cos(x);
plot(x,y1,...%this is the main point of the tutorial;1st plot x with respect to y1
'-*r',...%this is the sin(x) graph line properties
x,y2,...%2nd plot x with respect to y2
'--og');%this is the cos(x) graph line properties
grid on
xlabel('X');
ylabel('Y');
title('Plotting 2 graph in one figure');

No comments:

Post a Comment