I would like to define an anonymous function that takes a vector, but I am unable to achieve that unless every element in the vector is specified:
Data =
[ X11 X12;
X21 X22];
Iteration #1: V -> [X11 X12]
(desired row of values to be passed into 'some_func' at each iteration).
Iteration #2: V -> [X21 X22]
This works:
good_func_handle = @(a1,a2) some_func([a1,a2],bla,bla)
output = arrayfun(good_func_handle,Data(:,1),Data(:,2)) -> to avoid having to write a for loop
This doesn't work:
bad_func_handle = @(vec) some_func(vec,bla,bla)
output = arrayfun(bad_func_handle,Data)
When this is called only the first element X11
is passed in to some_func
but not X11
and X12
.
Is there a way to set up the function to take a vector variable as input instead of having to specify all elements in the vector?