Borrar filtros
Borrar filtros

convert a matrix with some zero to non zero txt file

1 visualización (últimos 30 días)
Jack Ie
Jack Ie el 4 de Abr. de 2016
Editada: Azzi Abdelmalek el 4 de Abr. de 2016
for example I have this matrix: [ 1 2 3 ; 1 0 0 ; 0 0 0; 4 5 6] I want to save it to a txt file: 1 2 3 1 4 5 6 (also delete zero rows completely.)

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 4 de Abr. de 2016
Editada: Azzi Abdelmalek el 4 de Abr. de 2016
a=[ 1 2 3 ; 1 0 0 ; 0 0 0; 4 5 6] I
for k=1:size(a,1)
b=a(k,:)
b=b(b~=0);
dlmwrite('file1.txt',b,'-append')
end

Más respuestas (0)

Categorías

Más información sobre Cell Arrays 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