フィルターのクリア

convert a matrix with some zero to non zero txt file

1 回表示 (過去 30 日間)
Jack Ie
Jack Ie 2016 年 4 月 4 日
編集済み: Azzi Abdelmalek 2016 年 4 月 4 日
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.)

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 4 月 4 日
編集済み: Azzi Abdelmalek 2016 年 4 月 4 日
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 件)

カテゴリ

Help Center および File ExchangeCell Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by