matlab中如何定义一个没有固定输入变量的函数

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/29 20:53:51
matlab中如何定义一个没有固定输入变量的函数
xTMA+^Ġ"%qYP3$ =CwIADYeAV/ (i_DVO$'0zwVNb498}|r~2t:z89{690vp~?|7=zNdPO[;AC)r?հkdbURa8׵aJ r&e R((pm,>i>m]ԾuhOd(x6%Ω#Y-ㆭ%s[w 4O#IۖRo j})Z>pBL>Zd^jfTqm** (HȺJPiV62d3U(䄽Eh}.&3b%z(" 8+"tP;/!)6)XQ {Vvząx㇛҈ d6vuK6EWo6'

matlab中如何定义一个没有固定输入变量的函数
matlab中如何定义一个没有固定输入变量的函数

matlab中如何定义一个没有固定输入变量的函数
>> help varargin
VARARGIN Variable length input argument list.
Allows any number of arguments to a function. The variable
VARARGIN is a cell array containing the optional arguments to the
function. VARARGIN must be declared as the last input argument
and collects all the inputs from that point onwards. In the
declaration, VARARGIN must be lowercase (i.e., varargin).

For example, the function,

function myplot(x,varargin)
plot(x,varargin{:})

collects all the inputs starting with the second input into the
variable "varargin". MYPLOT uses the comma-separated list syntax
varargin{:} to pass the optional parameters to plot. The call,

myplot(sin(0:.1:1),'color',[.5 .7 .3],'linestyle',':')

results in varargin being a 1-by-4 cell array containing the
values 'color', [.5 .7 .3], 'linestyle', and ':'.

See also varargout, nargin, nargout, inputname, function, lists, paren.
Reference page in Help browser
doc varargin