separate cell arrays by comma
11 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Jan
2017 年 4 月 17 日
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);
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Spreadsheets についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!