필터 지우기
필터 지우기

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 CenterFile Exchange에서 Cell Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by