From: Luca Cerone on
Thanks guys,
but actually I wanted to know if there is a built-in function..
similar to the deal for cells!
As we're talking, why wouldn't you suggest to assign variables
such a way?
I have a vector vec of parameters (I get it from fmincon).
I have to use these parameters into an ode,
so instead of remembering the order of the parameters
in the vector I prefer to create a function [a1,a2,a3]=setParam(param)
that assign the right value to each parameter.
This way if I make a mistake I only have to change the setParam function
instead of looking in the code everytime I'm using it.
If there is a more effective/elegant way any advice is accepted!
Cheers, -Luca
From: Walter Roberson on
Luca Cerone wrote:
> Thanks guys,
> but actually I wanted to know if there is a built-in function..
> similar to the deal for cells!

Sorry, No there is not. Converting to cell and using deal on the {:} of the
cell is the only mechanism for mass assignment.

> As we're talking, why wouldn't you suggest to assign variables
> such a way?

http://matlabwiki.mathworks.com/MATLAB_FAQ#How_can_I_create_variables_A1.2C_A2.2C....2CA10_in_a_loop.3F


> I have to use these parameters into an ode,
> so instead of remembering the order of the parameters
> in the vector I prefer to create a function [a1,a2,a3]=setParam(param)
> that assign the right value to each parameter.
> This way if I make a mistake I only have to change the setParam function
> instead of looking in the code everytime I'm using it.
> If there is a more effective/elegant way any advice is accepted!

I suggest you consider using fields of a structure. You may wish to use
cell2struct to build the structure.