The Math Forum

Search All of the Math Forum:

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

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Advanced colon indexing
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  

Posts: 77
Registered: 12/7/04
Advanced colon indexing
Posted: May 1, 2013 5:35 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hi! Consider this:

>> clear M, M(:,:,:,1,:)=rand(10,10,2,1,5); size(M)
ans =
10 10 2 1 5
>> clear M, M(:,:,:,1,:)=rand(10,10,1,1,5); size(M)
ans =
10 10 5
>> clear M, M(:,:,1,1,:)=rand(10,10,1,1,5); size(M)
ans =
10 10 1 1 5

Why doesn't the 2nd code line behave like the 1st one and the 3rd one do? (i.e. maintaining the 5-D shape of the array)

Isn't a colon allowed to represent a singleton dimension? (3rd dimension in the second code line)

Can you please pinpoint the according passage in the documentation?

Thank you!

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

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.