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:
Matrix Manipulation

Subject: Matrix Manipulation

From: Elnaz

Date: 28 Feb, 2013 22:14:09

Message: 1 of 2

Hi all,

How should I index a matrix when I want to use all the columns except for one?
For example I want to say G(:, everything - 4th column). How should I write that?

Thanks,
Elnaz

Subject: Matrix Manipulation

From: Steven_Lord

Date: 28 Feb, 2013 22:30:30

Message: 2 of 2



"Elnaz " <ebsadeghian@gmail.com> wrote in message
news:kgokrh$30k$1@newscl01ah.mathworks.com...
> Hi all,
> How should I index a matrix when I want to use all the columns except for
> one?
> For example I want to say G(:, everything - 4th column). How should I
> write that?

Assuming G has at least 3 columns:

G(:, [1:3 5:end])

If G does have 3 columns, END is 3 and (5:3) is empty.

If you want to exclude several columns, look at SETDIFF or make a copy of G
then delete the columns you want to exclude from the copy.

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

Tags for this Thread

No tags are associated with 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