Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Question on multidimensional array
Replies: 3   Last Post: Oct 16, 2012 3:11 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Loren Shure

Posts: 991
Registered: 12/7/04
Re: Question on multidimensional array
Posted: Oct 16, 2012 3:11 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"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/




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.