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

1 visualización (últimos 30 días)
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.

Respuesta aceptada

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

Iniciar sesión para comentar.

Más respuestas (1)

Stuart Layton
Stuart Layton el 28 de Jun. de 2011
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.

Categorías

Más información sobre Argument Definitions en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by