Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

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

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.

Contact us