Borrar filtros
Borrar filtros

Delet zeros after final number

2 visualizaciones (últimos 30 días)
Mahsa
Mahsa el 25 de Sept. de 2014
Comentada: Stephen23 el 26 de Sept. de 2014
Dear all, I'm looking for an efficient way to delete zeros after final number in MATLAB,
A= [ 5 6 0 3 2 0 9 0 0 0 0 0 0]
B = [ 5 6 0 3 2 0 9]
Thank you so much,
  1 comentario
Stephen23
Stephen23 el 26 de Sept. de 2014
Technically speaking, zero is also a number...

Iniciar sesión para comentar.

Respuesta aceptada

dpb
dpb el 25 de Sept. de 2014
A=A(1:find(A,1,'last'));
  1 comentario
Mahsa
Mahsa el 25 de Sept. de 2014
It works, that you so much

Iniciar sesión para comentar.

Más respuestas (1)

Mikhail
Mikhail el 25 de Sept. de 2014
There are plenty of ways to do that. For instance, find(A) will find indexes of all nonzero elements. So you can write:
B= A(1:max(find(A)))
max(find(A)) - index of the last nonzero element in A

Categorías

Más información sobre Matched Filter and Ambiguity Function en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by