
Re: Question on multidimensional array
Posted:
Oct 16, 2012 3:11 PM


"Paulo Guimaraes" wrote in message news:k5hnsu$4r1$1@newscl01ah.mathworks.com...
"James Tursa" wrote in message <k5hn0q$184$1@newscl01ah.mathworks.com>... > "Paulo Guimaraes" wrote in message > <k5hm4g$r3s$1@newscl01ah.mathworks.com>... > > Dear colleagues, if I have a matrix A I can apply a condition and change > > all elements of the matrix in a single line of code. As in > > > > A=[0, 12, 3; 9; 3;1]; > > A(A>3)=1 > > A=[0, 1, 3; 1; 3;1]; > > > > Is there any similar option for multidimensional arrays (e.g., each > > element of A is now determined by n numbers in which n>2)? > > The same exact syntax for 2D matrices also works for nD arrays. > > James Tursa
>>Sorry I was not clear, I want to apply the condition just to one of the >>dimensions, not the entire object. For example, I want to do:
>>if A(:, :, 3)>1 than A(:,:,3)=1.
A(:,:,3) = min(1,A(:,:,3));
Loren http://blogs.mathworks.com/loren/ http://www.mathworks.com/matlabcentral/

