필터 지우기
필터 지우기

Throwing out bad data

조회 수: 9 (최근 30일)
Kendra Wright
Kendra Wright 2014년 11월 10일
댓글: Kendra Wright 2014년 11월 10일
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

채택된 답변

Kelly Kearney
Kelly Kearney 2014년 11월 10일
You don't need to loop:
x = x(count == 10,:);
  댓글 수: 1
Kendra Wright
Kendra Wright 2014년 11월 10일
Wow, I knew I was making that much more difficult than necessary. Thank you

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by