This function is much more useful. There are many times I have found myself wanting to find the maximum signal intensity of a set of images across the fourth dimension, for example the maximum intensity of [cci lang="matlab"]A(:,:,10,:)[/cci]. You can’t do this simply as you can’t do something like [cci lang="matlab"]A(:,:,10,:)(:)[/cci]. So, I wrote a simple function called [cci lang="matlab"]flat.m[/cci] to return a 1D version of the input matrix [cci lang="matlab"]flat(A) = A(:);[/cci]. So now you can call [cci lang="matlab"]mm = max( flat( A(:,:,10,:) ) );[/cci].
[cc lang="matlab"]
function vec = flat(v)
vec = v(:);
[/cc]