Effacer les filtres
Effacer les filtres

Filtering the data using IF

2 vues (au cours des 30 derniers jours)
Jakub Nosek
Jakub Nosek le 6 Nov 2016
Commenté : Jakub Nosek le 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];

Réponse acceptée

KSSV
KSSV le 6 Nov 2016
idx=DF_x==0;
DF_x0=DF_x(idx);
t0=Time(idx);
iwant=[t0 DF_x0];
  1 commentaire
Jakub Nosek
Jakub Nosek le 6 Nov 2016
Thanks! It works!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Statistics and Linear Algebra dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by