How to define a function that can have multiple variables.

1 回表示 (過去 30 日間)
C Zeng
C Zeng 2012 年 6 月 11 日
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.

採用された回答

the cyclist
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 件のコメント
the cyclist
the cyclist 2012 年 6 月 12 日
I edited my reply to include a web page that has an example.
C Zeng
C Zeng 2012 年 6 月 12 日
thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Types についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by