Listing the input arguments and values of a function in a Matrix

조회 수: 1 (최근 30일)
Is there a way to list the input arguments in a function by outputting them in a Cell array
[input1 = x; input2 = y; input3 =z; ..etc]
I have a large function with about 20 inputs and want to check on them all before I proceed.

채택된 답변

Fangjun Jiang
Fangjun Jiang 2011년 6월 28일
Yes, you can. Use this example:
InputArgument={'this is the string for the pattern','pattern'}
strfind(InputArgument{:});
  댓글 수: 3
Sean de Wolski
Sean de Wolski 2011년 6월 28일
You want varargin, it'll work for EVERYTHING!
Fangjun Jiang
Fangjun Jiang 2011년 6월 28일
Yes.
InputArguments={randint(1,5),2}
find(InputArguments{:})

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Stuart Layton
Stuart Layton 2011년 6월 28일
William, i'm thinking you want to use varargin. By defining the input arguments as varargin you can have as many input arguments as you want. Parsing this is pretty easy too, its simply a cell array of the arguments. Look at using the InputParser to parse it.

카테고리

Help CenterFile Exchange에서 Argument Definitions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by