MATLAB Answers


delete rows based on whether the value in column 10 of the respective row is equal to one or not

Asked by Locks
on 24 Apr 2013


I tried to solve the problem described above with the following formula:

      rowsToDelete8 = dataset(:,10)==1;
      dataX(rowsToDelete8, :) = [];

where dataset is double and the 10th column is either 1 or 0

While doing this, I get the following error message:

Index of element to remove exceeds matrix dimensions.
Error in deleteSeriesWithOnlyFourElements (line 67)
    dataX(rowsToDelete8, :) = [];

I do not really understand why it's not working



No products are associated with this question.

1 Answer

Answer by Image Analyst
on 24 Apr 2013
 Accepted answer

rowsToDelete8 was based on looking at dataset, not dataX, but then you try to use it in dataX, which is evidently not the same size as dataset.

Also, don't use "delete" as the name of a variable like you did in "dataset=[dataset,delete];"

  1 Comment

on 24 Apr 2013

That was exactyl the mistake, thanks

Join the 15-year community celebration.

Play games and win prizes!

Learn more
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

MATLAB Academy

New to MATLAB?

Learn MATLAB today!