How to eliminate zeros from array

e.g I want to make this:
1,1,1,1,0,0 1,1,0,0,0,0 1,0,0,0,0,0 1,1,1,1,1,0 into this:
1,1,1,1 1,1 1 1,1,1,1,1

1 comentario

Can you give a an example of these two arrays in working matlab code?
Array1 = ...
Array2 = ...

Iniciar sesión para comentar.

Respuestas (1)

Jos (10584)
Jos (10584) el 14 de Mzo. de 2018
a(~logical(a)) = []

5 comentarios

Sarumathi C
Sarumathi C el 14 de Mzo. de 2018
Sir the all values coming in single column but I need location of non zero values not change and only zeros should be eliminated to find difference between two rows when both row have same number of non zero values
Jos (10584)
Jos (10584) el 14 de Mzo. de 2018
You cannot simply eliminate elements in a regular array without changing the shape, you should replace them by something else.
What do you exactly mean by " find difference between two rows " ?
Sarumathi C
Sarumathi C el 14 de Mzo. de 2018
My output like 2 0 0 0; 5 5 0 0; 6 7 0 0; 1 5 8 0; I need to covert like 2; 5 5; 6 7; 1 5 8; I need to find out the difference between the 2nd row and 3rd row because 1St have different length comparing with second row but 2&3 have same length of values so I need output like 2; 1{(6-5)} {(7-2)} 2; 1 5 8;
Jos (10584)
Jos (10584) el 14 de Mzo. de 2018
Please use valid matlab notation for the examples ...
Birdman
Birdman el 14 de Mzo. de 2018
Editada: Birdman el 14 de Mzo. de 2018
And maybe this should be a new question since it is hard to pay attention to this between comments, also you are off the topic of the question.

Iniciar sesión para comentar.

Categorías

Productos

Preguntada:

el 14 de Mzo. de 2018

Editada:

el 14 de Mzo. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by