myvarin.m

来自「从MatlabSimulink模型到代码实现」· M 代码 · 共 23 行

M
23
字号
function myvarin(varargin)
%MYVARIN receive variable input points and plot them
%This function is just a simple example of which the 
%number of input arguments is variable.

%check if the number of input points is more than one
if nargin <=1
    disp('Usage:myvarin([x1,y1],[x2,y2],...,[xN,yN]),where N>=2');
    disp('Input more than one points,Please!');
    return;
end

%get[x1,x2,...,xN] and [y1,y2,...,yN] from input points
for i=1:nargin 
    x(i)=varargin{i}(1);
    y(i)=varargin{i}(2);
end

xmin=min(0,min(x));
ymin=min(0,min(y));

plot(x,y);
axis([xmin fix(max(x)+1) ymin fix(max(y)+1)]);% adjust axis range

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?