'So the function should rather be termed submax.'
-yes
'Wouldn't it be better that all indices or subscripts are returned where A==max(A)?' -sometimes, in my case not...
Wouldn't it be better to return them as row vector?'
- not necessarily. and the syntax (see example) is not maximum=A(ind) but maximum=A(ind{:})
anyway, i thought the recursive loop was quite elegant, but of course, using the linear index is faster and easier. i was not aware of maxn by douane hanselman and recommend to use his routine.
indmax finds the subscripts and not single index. So the function should rather be termed submax.
indmax returns only the first occurrence of max(A). Wouldn't it be better that all indices or subscripts are returned where A==max(A)?
indmax returns the indices (subscripts) as cell array. Wouldn't it be better to return them as row vector? Because this here (taken from your example) returns an error.
A = cat(3,magic(4),flipud(magic(4)+1));
[ind,maxi]=indmax(A)
ind =
[4] [1] [2]
maxi =
17
maximum = A(ind)
??? Error using ==> subsindex
Function 'subsindex' is not defined for values of class 'cell'.