Filtering the data using IF

1 回表示 (過去 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 Center および File ExchangeStatistics and Linear Algebra についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by