How to define a function that can have multiple variables.

조회 수: 2 (최근 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 CenterFile Exchange에서 Direction of Arrival Estimation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by