필터 지우기
필터 지우기

Filtering the data using IF

조회 수: 6 (최근 30일)
Jakub Nosek
Jakub Nosek 2016년 11월 6일
댓글: Jakub Nosek 2016년 11월 6일
Hi, I have 2 variables (matrixes) Time (5810x1) and DF_x (5810x1). I'd like to display only DF_x rows that are equal to 0 and its Time (each row in matrix called Time corresponds to the same row in matrix called DF_x). I have created a code shown below but it doesn't work. In the DF_x matrix there are 12 rows with a value equal to 0, which means that the code should display 12 rows and 2 colums- DF_x and a given time for each value of DF_x. Unfortunately, the result shows more than 1300 DF_x rows all with zeros (which is not correct). It also shows 12 Time rows with a correct time but the rest is all zeros as well. Could you please help me to make this work? Thank you!
[m,n]=size(DF_x);
for i=1:m
for j=1:n
if DF_x(i,j)==0
DF_acas(i,j)=DF_x(i,j);
Time_acas(i,j)=Time(i,j);
end
end
end
acas=[Time_acas DF_acas];

채택된 답변

KSSV
KSSV 2016년 11월 6일
idx=DF_x==0;
DF_x0=DF_x(idx);
t0=Time(idx);
iwant=[t0 DF_x0];
  댓글 수: 1
Jakub Nosek
Jakub Nosek 2016년 11월 6일
Thanks! It works!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Statistics and Linear Algebra에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by