How do I remove NaN and / or interpolated data?
17 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Thaís Fernandes
le 25 Jan 2019
Commenté : Thaís Fernandes
le 25 Jan 2019
Hello.
I have the vectors
A=[1 NaN 3 ;...
4 NaN 6 ;...
5 NaN NaN;...
0 NaN NaN;...
7 8 NaN;...
0 0 9] ;...
(variable A) and t=0:1:5; (time), and I would like to do the following: If in a column there are more than 4 rows with NaN I exclude this column, otherwise I interpolate this data.
I have no idea how to do this. Can anyone help me giving suggestions?
Thanks.
1 commentaire
Réponse acceptée
Guillaume
le 25 Jan 2019
A=[1 NaN 3
4 NaN 6
5 NaN NaN
0 NaN NaN
7 8 NaN
0 0 9]
%remove columns with more than 4 nans
A(:, sum(isnan(A), 1) >= 4) = [];
%replace nans by interpolated values. Requires R2016b or later
A = fillmissing(A, 'linear')
1 commentaire
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Interpolation 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!