I have a 1x2 cell array. Lets say David x Ian. I want to write these two names in a csv file. When I write it becomes D,a,v,i,d,I,a,n. I want it as David,Ian.
Thanks in advance.

댓글 수: 1

Jan
Jan 2017년 4월 17일
편집: Jan 2017년 4월 17일
You forgot to mention how you try to write the file. "David x Ian" is not meaningful. I guess you mean:
C = {'David', 'Ian'};

댓글을 달려면 로그인하십시오.

답변 (1개)

Jan
Jan 2017년 4월 17일

0 개 추천

csvwrite is not the proper command, because it handles numerical data only.
C = {'David', 'Ian'};
fid = fopen('Test.csv', 'w');
if fid == -1, error('Cannot open file for writing.'); end
fmt = [repmat('%s,', 1, size(C, 2) - 1), '%s\n'];
fprintf(fid, fmt, C{:});
fclose(fid);

카테고리

태그

질문:

2017년 4월 17일

편집:

Jan
2017년 4월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by