Removing all non NaN Values to a new matrix.
60 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
BdS
el 5 de Feb. de 2020
Respondida: BdS
el 5 de Feb. de 2020
Hi,
I have got a 261x3733 double array temp with numbers and NaN.
I would like to get in matrix a only the nonnan values. Conditions: a should be of the same size as temp and all nonnan values shouldn't change place.
I tried this code:
a=temp(~isnan(temp))
However I get the vector with size 330227x1
Do you have any suggestions for solving this issue?
2 comentarios
Adam
el 5 de Feb. de 2020
What you want in place of the NaNs? You can't have nothingness is elements of a numeric array. If you extract only the non-nan values then you inevitably loose the shape of the matrix.
BN
el 5 de Feb. de 2020
I'm Agree with Adam.
So you want to remove NaN and save the result in a new matrix BUT you want a new matrix to have exactly the same size as an original matrix?
What do you want to instead of NaN?
This data seems to be the temperature. You can fill them using the nearest station linear regression or using fillmissing function.
Respuesta aceptada
JESUS DAVID ARIZA ROYETH
el 5 de Feb. de 2020
a solution:
a=sparse(temp)
a(isnan(a))=[]
0 comentarios
Ver también
Categorías
Más información sobre ANOVA en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!