Throwing out bad data

9 visualizaciones (últimos 30 días)
Kendra Wright
Kendra Wright el 10 de Nov. de 2014
Comentada: Kendra Wright el 10 de Nov. de 2014
I have a large data set where sometimes we have a "bad" data point. The the column "count" in the matrix "x" below, I have the value 10 if all of the data points were taken, or NaN or some other number if there was a problem. I'm working on filtering out those points. So when I have count(i) does not equal 10, I want to delete the entire row.
This is most certainly not the simplest way of doing this, but I am trying to run two separate loops to search for bad data points and delete the row. The first loop which looks for numbers not equal to 10 seems to work. The second loop does not, although it deletes most of the values of the points that have a NaN value (all but 3). Could someone either help me see how to fix this piece of code or suggest a different method?
L = length(Data{1});
x = horzcat(DateNumber,RedScat,GreenScat,count);
for i=1:L
if count(i) ~= 10
x(i,:)=[];
end
end
L2 = length(x);
countedit = x(:,end);
y = isnan(countedit);
for i=1:L2
if y(i) == 1
x(i,:)=[];
end
end

Respuesta aceptada

Kelly Kearney
Kelly Kearney el 10 de Nov. de 2014
You don't need to loop:
x = x(count == 10,:);
  1 comentario
Kendra Wright
Kendra Wright el 10 de Nov. de 2014
Wow, I knew I was making that much more difficult than necessary. Thank you

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by