convert a matrix with some zero to non zero txt file
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Jack Ie
le 4 Avr 2016
Modifié(e) : Azzi Abdelmalek
le 4 Avr 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.)
0 commentaires
Réponse acceptée
Azzi Abdelmalek
le 4 Avr 2016
Modifié(e) : Azzi Abdelmalek
le 4 Avr 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
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Cell Arrays dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!