I have a MATLAB function which returns a 4-element vector, e.g. [1 2 3 4]
. I would like to use that function output to access the corresponding element in an existing 4-dimensional vector, i.e. vec(1, 2, 3, 4)
. Is there a way to do this without storing the result and then explicitly accessing the elements, as in the following?
result = f(blah);
myElement = vec(result(1), result(2), result(3), result(4));
In my (Python-influenced) head, the answer looks something like this:
result = f(blah);
myElement = vec(*result); % or vec(toSubscripts(result)); or similar
The *
operator in Python expands a list into comma-separated arguments. Is there an analogous operator or function in MATLAB that will help solve my problem?