MATLAB: Added functionallity for ind2sub

im2col

I was using ind2sub with a 2D matrix (IND) for a matrix of 2D size and only supplied one output (ans).
Example:
>> ind2sub([3,3], [2,2,2; 3,3,3]);
The function is supposed to have an output of something like
[A,B] = ind2sub(...
however I wanted to use it in the middle of a line, where there is only one output matrix. As it is now, the output of the above example function is [2,2,2; 3,3,3].
My question is if ind2sub could have the added functionality so that if there is only one output matrix, the output matrices could be combined into the first non-utilized dimension. In the example (and in my case) the third dimension (Ex. size(ind2sub(…)) = [2,3,2]).
Have a good day,
Jude

Best Answer

You could create a product suggestion with Mathworks, but I doubt they would implement it. You can define you own small .m that has this functionality, by running ind2col and checking nargout to see whether to combine the outputs or not.
By the way, ind2col is not a MATLAB function, and is also not present in the File Exchange. Did you perhaps mean ind2sub() ?