필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

How to write this cell to a csvfile?

조회 수: 2 (최근 30일)
DEVANAND
DEVANAND 2014년 4월 4일
마감: MATLAB Answer Bot 2021년 8월 20일
Hi all, If I have a cell with contents like
{'X','Y';
1,'a';
2,'c';
3,'c'}
Now I want to convert this cell to a csvfile like below:
X,Y
1,a
2,c
3,c
How to do this using csvwrite.

답변 (1개)

DEVANAND
DEVANAND 2014년 4월 4일
OK I did it. This is how I did:
fid = fopen('junk.csv','w');
fprintf(fid,'%s,%s\n',xx{1,:}); % cell name xx with 4*2 elements
for i = 2:4
fprintf(fid,'%d,%s\n',xx{i,:});
end
fclose(fid);
  댓글 수: 2
Jan
Jan 2014년 4월 4일
Alternative without a loop:
xxt = xx(2:4, :)';
fprintf(fid,'%d,%s\n',xxt{:});
DEVANAND
DEVANAND 2014년 4월 4일
This is a better solution. Thank you.

이 질문은 마감되었습니다.

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by