For any function, I am able to dictate the variables to be returned by explicitly defining how many outputs I am expecting [out1,out2,...,outn] = ...
Edit: Being able to maximize potential # of outputs would also be useful
Example problem
The following code does exactly what is expected (yes, it is redundant with myArray(IND) = 1;
)
[I,J] = ind2sub(size(myArray),IND)
myArray(I,J) = 1;
When I try to pass the function arguments directly, I don't get the results I wannt
myArray(ind2sub(size(myArray),IND)) = 1;
I effectively get myArray(I) = 1;
when I wanted myArray(I,J) = 1;
Question
How can I dictate how many output variables are returned without explicitly defining my output arguments?
I expect some function in the eval()
family or some typecasting [],{},(:), etc.
will do the trick but I have not seen any documentation or gotten any of them to work.