gusucode.com > 《精通matlab 7》包括配套光盘 > 配套光盘里的程序附件/Ex-23/Ex2301.m

    %例23-1 MATLAB绘图函数实例
function createfigure(x1, y1)
%CREATEFIGURE(X1,Y1)
%  X1:  vector of x data
%  Y1:  matrix of y data
 
%  Auto-generated by MATLAB on 16-Feb-2006 14:38:25
 
%% Create figure
figure1 = figure('PaperPosition',[0.6345 6.345 20.3 15.23],'PaperSize',[20.98 29.68]);
 
%% Create axes
axes1 = axes('Parent',figure1);
axis(axes1,[0 6.283 -2 2]);
title(axes1,'sin(x)/sin(2x)/sin(3x)');
xlabel(axes1,'x');
ylabel(axes1,'y');
box(axes1,'on');
hold(axes1,'all');
 
%% Create multiple lines using matrix input to plot
plot1 = plot(x1,y1);
 
%% Create text
text1 = text(...
  'Position',[1.136 -0.9532 0],...
  'String','y=sin(x)',...
  'VerticalAlignment','baseline',...
  'Parent',axes1);
 
%% Create text
text2 = text(...
  'Position',[2.266 -0.8947 0],...
  'String','y=sin(2x)',...
  'VerticalAlignment','baseline',...
  'Parent',axes1);
 
%% Create text
text3 = text(...
  'Position',[3.395 0.8947 0],...
  'String','y=sin(3x)',...
  'VerticalAlignment','baseline',...
  'Parent',axes1);