How to define a function that can have multiple variables.
2 次查看(过去 30 天)
显示 更早的评论
For example f(x,y,z) or f(x,y), z is optional. If I list three variables then system uses f(x,y,z), if only 2 variables uses f(x,y).
I know how to use it by nargin function, is there better way to do so?
Thanks.
0 个评论
采纳的回答
the cyclist
2012-6-11
When you say you know how to do it by nargin, does that mean you are also familiar with varargin? That sounds like what you want.
>> doc varargin
There is an example on this page:
3 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!