Replace NaN with corresponding elements in another array.
22 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I can find the locations of all the NaNs in an array, but how can I replace those elements with the corresponding elements of another array.
0 commentaires
Réponses (1)
James Tursa
le 2 Fév 2015
A = original array with NaNs in it
B = array with desired replacement values
x = isnan(A);
A(x) = B(x);
2 commentaires
James Tursa
le 5 Fév 2015
The zeros in what resulting array? If you have an array C the same size as A and you want to replace the zeros in C with the corresponding values from A, then use a similar technique as above. E.g.,
x = (C == 0);
C(x) = A(x);
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!