Convert zeros to NAN
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I have a matrix (N rows and M columns). It consists of integer values. I want to convert all the zero values from rows 1:N and columns 3:M to NaN. Is there any way to do so.
Thanks, Nancy
0 comentarios
Respuesta aceptada
Sean de Wolski
el 14 de Jun. de 2011
One of many ways
idx = ~A;
idx(:,1:2) = false;
A(idx) = nan;
3 comentarios
Sean de Wolski
el 14 de Jun. de 2011
Yes. It sets any value that was a zero value (the ~ (not) command) in the first definition to be false so that it doesn't show up in the nan assignment.
Más respuestas (0)
Ver también
Categorías
Más información sobre Data Type Conversion 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!