Extracting zeros from vectors
Mostrar comentarios más antiguos
I need to extract zeros from a vector while keeping the same order of elements in s.
Like this :
S=[1 0 0 2 3 0 0 0 2 1 0 4 0 0 0 0 1 0 2]
S1=[1 2 3 2 1 4 1 2]
Respuesta aceptada
Más respuestas (1)
Andrei Bobrov
el 24 de Oct. de 2018
S1 = S(S ~= 0)
Categorías
Más información sobre Modeling en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!