Access element of MATLAB multi-dimensional array specified by another vector -


this question has answer here:

i have matlab function returns 4-element vector, e.g. [1 2 3 4]. use function output access corresponding element in existing 4-dimensional vector, i.e. vec(1, 2, 3, 4). there way without storing result , explicitly accessing elements, in following?

result = f(blah); myelement = vec(result(1), result(2), result(3), result(4)); 

in (python-influenced) head, answer looks this:

result = f(blah); myelement = vec(*result); % or vec(tosubscripts(result)); or similar 

the * operator in python expands list comma-separated arguments. there analogous operator or function in matlab solve problem?

there *result in matlab, it's called comma separated list. unfortunately can not create comma separated list array, conversion cell first required:

result=(num2cell(f(blah))); myelement=v(result{:}); 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -