Got Questions? Get Answers.
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:
Delete Even Rows & Columns

Subject: Delete Even Rows & Columns

From: J D

Date: 18 Dec, 2008 15:15:05

Message: 1 of 4

I have a 288x157 matrix. I need to delete all of the even rows and columns. Is their an easy way to do this?

For example/

ZZ =

     1 6 11 16
     2 7 12 17
     3 8 13 18
     4 9 14 19
     5 10 15 20

XX =

     1 11
     3 13
     5 15

JD

Subject: Delete Even Rows & Columns

From: Walter Roberson

Date: 18 Dec, 2008 15:23:36

Message: 2 of 4

J D wrote:
> I have a 288x157 matrix. I need to delete all of the even rows and columns. Is their an easy way
> to do this?

ZZ = ZZ(1:2:end, 1:2:end);

--
.signature note: I am now avoiding replying to unclear or ambiguous postings.
Please review questions before posting them. Be specific. Use examples of what you mean,
of what you don't mean. Specify boundary conditions, and data classes and value
relationships -- what if we scrambled your data or used -Inf, NaN, or complex(rand,rand)?

Subject: Delete Even Rows & Columns

From: M.Black

Date: 18 Dec, 2008 15:23:21

Message: 3 of 4

this should do it:

ZZ(2:2:end,:)=[];
ZZ(:,2:2:end)=[];

Subject: Delete Even Rows & Columns

From: J D

Date: 18 Dec, 2008 16:22:02

Message: 4 of 4

Thanks, great solution.

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