MATLAB: Generating function depending on user input -


i new matlab , having trouble following.

i using external function, "allcomb" allows me create combination of elements arrays.

for example, have array c [1 2 3 4] , integer x of value between 1 20. results want simply,

if x 1, function allcomb(c) if x 2, function allcomb(c,c) if x 6, function allcomb(c,c,c,c,c,c) 

... on.

instead of creating if condition, better way of doing it?

thanks interest

the long way using strings not necessary, use comma separated list operator : instead:

c = [1 2 3 4]; x = 2  in = repmat( {c}, x, 1 )  allcomb( in{:} ) 

as example allcomb displays input:

function allcomb( varargin ) celldisp(varargin) end 

returns x = 2:

varargin{1} =       1     2     3     4  varargin{2} =       1     2     3     4 

and x = 4:

varargin{1} =       1     2     3     4  varargin{2} =       1     2     3     4  varargin{3} =       1     2     3     4  varargin{4} =       1     2     3     4 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -