Azzera filtri
Azzera filtri

Filtering the data using IF

2 visualizzazioni (ultimi 30 giorni)
Jakub Nosek
Jakub Nosek il 6 Nov 2016
Commentato: Jakub Nosek il 6 Nov 2016
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];

Risposta accettata

KSSV
KSSV il 6 Nov 2016
idx=DF_x==0;
DF_x0=DF_x(idx);
t0=Time(idx);
iwant=[t0 DF_x0];

Più risposte (0)

Categorie

Scopri di più su Statistics and Linear Algebra in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by