How to use the index ? how to drop elements from a matrix ?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Islam
le 30 Nov 2013
Réponse apportée : Andrei Bobrov
le 30 Nov 2013
I have a matrix b(j,w) = b(3,4)
b= [
0.0913 NaN NaN NaN
0.0913 NaN NaN NaN
0.0913 NaN NaN NaN ]
and g(j,w)=g(3,4)
60 60 60 60
70 70 70 70
75 75 75 75
I want to drop the elements in g that have a correspondent NAN value in b.
0 commentaires
Réponse acceptée
Wayne King
le 30 Nov 2013
Modifié(e) : Wayne King
le 30 Nov 2013
One of many ways:
b= [
0.0913 NaN NaN NaN
0.0913 NaN NaN NaN
0.0913 NaN NaN NaN ];
g = [60 60 60 60
70 70 70 70
75 75 75 75];
idx = ~isnan(b);
g = g(idx>0);
0 commentaires
Plus de réponses (2)
Azzi Abdelmalek
le 30 Nov 2013
b= [ 0.0913 NaN NaN NaN
0.0913 NaN NaN NaN
0.0913 NaN NaN NaN ]
c=[ 60 60 60 60
70 70 70 70
75 75 75 75]
idx=any(~isnan(b),1)
c=c(:,idx)
0 commentaires
Andrei Bobrov
le 30 Nov 2013
b = [0.0913 NaN NaN NaN
0.0913 NaN NaN NaN
0.0913 NaN NaN NaN];
g = [60 60 60 60
70 70 70 70
75 75 75 75];
>> g(~isnan(b))
ans =
60
70
75
0 commentaires
Voir également
Catégories
En savoir plus sur NaNs 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!