Replacing NaN's in column of a Matrix

1 vue (au cours des 30 derniers jours)
Claire Hollow
Claire Hollow le 29 Mai 2020
Modifié(e) : Stephen23 le 29 Mai 2020
Hello! I feel tihs should be rather simply but for some reason I cannot get it to work.
I have a 2922x14 matrix. In random places in the second column there are 'NaN' and I'm trying to change all the 'NaN' to 250. Im trying to do a possible if-else (or anything that should work) statement to change all the NaN in just that second column to 250. Thank you ahead of time for the help!

Réponse acceptée

Stephen23
Stephen23 le 29 Mai 2020
Where M is your matrix:
X = isnan(M(:,2));
M(X,2) = 250;
  1 commentaire
Claire Hollow
Claire Hollow le 29 Mai 2020
Modifié(e) : Stephen23 le 29 Mai 2020
Work perfectly, thank you so much!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Creating and Concatenating Matrices 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