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 rows in matlab by column

Subject: Delete rows in matlab by column

From: C F

Date: 2 Sep, 2009 05:49:01

Message: 1 of 2

Hi,

I have a 1000 x 5 matrix and would like to delete all rows where the first column is greater than 10. Is there a simple way to do this (analagous to the "Drop if" command in stata.)

Or, better yet, is there a way to calculate the mean and standard deviation of the columns of a matrix for only those rows where the first column is greater than 10?

Thanks,
cf

Subject: Delete rows in matlab by column

From: Matt Fig

Date: 2 Sep, 2009 06:00:06

Message: 2 of 2

For example:

% Data
A = ceil(rand(20,5)*20)

% Delete rows where first column value is greater than 10
A = A(A(:,1)<=10,:) % Could also assign this to a new matrix, B and operate on it.
% Or: A(A(:,1)>10,:) = []

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