Thread Subject:
Advanced colon indexing

Subject: Advanced colon indexing

From: G

Date: 1 May, 2013 21:35:10

Message: 1 of 1

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!

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
matrix indexing G 1 May, 2013 21:39:18
rssFeed for this Thread

Contact us