Borrar filtros
Borrar filtros

I want to remove zeroes from an array. The array more zero per row. For example: a = [200.03 303.56 0 0 0; 155.23 0 0] Should be turned into a = [200.03 303.56; 155.23]

1 visualización (últimos 30 días)
I want to remove zeroes from an array. The array has exactly mote zero per row. For example:
a = [1 4 3 0 0 0; 1 5 0 0 0; 1 8 1 0 0; 5 4 4 0 0;1 5 2 0 0]
Should be turned into
a = [1 4 3; 1 5 5; 1 8 1; 5 4 4; 1
  1 comentario
KSSV
KSSV el 14 de Mzo. de 2018
a = [1 4 3 0 0 0; 1 5 0 0 0; 1 8 1 0 0; 5 4 4 0 0;1 5 2 0 0]
This is not correct......please correct your question properly.

Iniciar sesión para comentar.

Respuestas (1)

KSSV
KSSV el 14 de Mzo. de 2018
a = [1 4 3 0 0 0 1 5 0 0 0 1 8 1 0 0 5 4 4 0 0 1 5 2 0 0]
% b = [1 4 3 1 5 5 1 8 1 5 4 4 1 ] ;
b = a ;
b(a==0) = [] % remove zeros
b = a ;
b(b~=0) % pick non zeroes

Categorías

Más información sobre Images en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by