Removing zero values from an array
451 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Alice Stembridge
el 14 de Mayo de 2015
Comentada: Stephen23
el 21 de Mzo. de 2022
I have an n x 1 array containing values. For exmaple A =
1
0
0
2
0
3
I was wondering if it was possible to create another array except without the zero values. For example
B =
1
2
3
1 comentario
Respuesta aceptada
Star Strider
el 14 de Mayo de 2015
Using logical indexing, you can calculate ‘B’ in one line:
B = A(A~=0)
6 comentarios
Star Strider
el 14 de Mayo de 2015
Thank you Walter.
I was away for a few minutes with another Answer.
Más respuestas (0)
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!