How to extract NaN values from matrix?
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
studentmatlaber
el 14 de Abr. de 2022
Comentada: the cyclist
el 14 de Abr. de 2022
Hello to everyone. I have a 28x5 matrix and this matrix has NaN values in it. I want to create a new matrix by deleting these NaN values from my matrix. My new matrix should only consist of numbers. I also want to save the newly formed matrix as a 1-line vector. How can I do that.
I wrote a code like this to delete NaN values, but I couldn't get the right result. Thanks for your help.
x_T_est1n=x_T_est1(~isnan(x_T_est1(:,1))&~isnan(x_T_est1(:,2)),:);%NANs
0 comentarios
Respuesta aceptada
the cyclist
el 14 de Abr. de 2022
Here are two different ways:
M = [2 3;
5 NaN];
Mvec = M(not(isnan(M)))'
Mvec2 = M;
Mvec2(isnan(Mvec2)) = []
2 comentarios
the cyclist
el 14 de Abr. de 2022
M = [2 3;
5 NaN];
Mvec2 = M';
Mvec2(isnan(Mvec2)) = []
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical 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!