Finding and removing NaN values in a matrix
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Nancy
el 26 de Sept. de 2011
Comentada: Walter Roberson
el 3 de Ag. de 2017
Hi Guys,
I am dealing with matrices of the size 1268*100. I wish to eliminate certain rows from this matrix. I do certain operations to get integer values for the rows that I want to keep and NaN value for the ones I dont. How can I get the rows that have NaN values and use these numbers to eliminate the rows that I dont want in my main matrix.
Eg. if my column matrix has the following values= [1 2 3 NaN 3 4 NaN 5 7 NaN]
So I will need to eliminate rows 4 7 and 10 in my main matrix.
How do I go about doing that.
Thanks, Nancy
0 comentarios
Respuesta aceptada
Walter Roberson
el 26 de Sept. de 2011
Is it only necessary to refer to column 1, or are there other columns that might have nans that signal removal ?
If column 1 alone is enough, then you can use
values(isnan(values(:,1)),:) = [];
5 comentarios
Walter Roberson
el 3 de Ag. de 2017
Ahmed, that has the same problems I described for Shubham Maurya's suggestion.
Más respuestas (0)
Ver también
Categorías
Más información sobre NaNs 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!