NaN selective removal from a matrix
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Ziv Kassner
el 9 de Jul. de 2014
Respondida: Andrei Bobrov
el 9 de Jul. de 2014
I have a matrix like this: a=[NaN NaN NaN NaN;NaN NaN NaN NaN;2 3 NaN 4;9 4 NaN 4;3 9 NaN 3];
and i want to remove all the rows that contains only NaN's to: b=[2 3 NaN 4;9 4 NaN 4;3 9 NaN 3];
please help me,
Ziv.
0 comentarios
Respuesta aceptada
Jos (10584)
el 9 de Jul. de 2014
tf1 = isnan(a)
tf2 = all(a,2)
tf3 = ~tf2
b = a(tf3,:)
b2 = a(~all(isnan(a),2),:) % in one giant leap
Más respuestas (1)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!