Is there any way to pass multiple variables in a single structure/cell/vector/whatever to a function, so that I can avoid writing out all variables and call variables within function shortly by their names (rather than eg. structureName.variableName)?
In other words, instead of this:
a=1; b=2; c=3; ... z=24; myFun(a, b, c, ..., z)
(and inside my function:)
function myFun(a, b, c, ..., z) newVal = c % calling variable shortly by its name
I would like to have something like:
alphabet = struct('a', 1, 'b', 2, 'c', 3, ..., 'z', 24); myFun(alphabet)
(and inside my function:)
function myFun(alphabet) newVal = c % calling variable shortly by its name
Best Answer