How to substitue NaN cells in a column (or matrix) with the previous valid number?
Afficher commentaires plus anciens
Hi guys, pretty easy question i guess...
I have a very big matrix full of NaN values, thousands of them in each column. I need to replace them with the fist oldest value available..
Let's say that i have a column like this:
1
2
4
NaN
2
In this case i should replace NaN with 2. I have some complexities, for example i may not have a rectangular matrix and i could have some nan at the end of the column... in this case i should replace the nan with the first value "up".. Example:
1
3
2
NaN
NaN
In this case the NaN must become both 2.
I attach an example of a little .mat file ready to make some tries.
Thank you so much for the help.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur NaNs dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!