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:
Remove some columns from a matrix

Subject: Remove some columns from a matrix

From: Jerry

Date: 14 Feb, 2013 13:46:07

Message: 1 of 2

Hello,

A=rand (200, 450);

I would like to remove these columns (20, 36, 50:60, 71, 89) from 'A' . Should I use following command line to do this function? I wrote 50:60 since I need also to remove columns from 50 to 60.

A(:,20&36&50:60&&71&89)=[];

Thanks,
Jerry

Subject: Remove some columns from a matrix

From: Steven_Lord

Date: 14 Feb, 2013 14:46:02

Message: 2 of 2



"Jerry " <jerrycholo@gmail.com> wrote in message
news:kfipqu$o9t$1@newscl01ah.mathworks.com...
> Hello,
>
> A=rand (200, 450);
>
> I would like to remove these columns (20, 36, 50:60, 71, 89) from 'A' .
> Should I use following command line to do this function? I wrote 50:60
> since I need also to remove columns from 50 to 60.
>
> A(:,20&36&50:60&&71&89)=[];

No; that will only remove the first eleven columns from A (assuming the &&
in your message is a typo.)

Instead use:

A(:, [20 36 50:60 71 89]) = [];

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

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