フィルターのクリア

How to save a matrix having cell array into csv

2 ビュー (過去 30 日間)
Jake
Jake 2013 年 8 月 8 日
Hi,
I really want your help. Here is my code...
name = [{Jake}; {Mike}];
age = [24; 22];
age = cellstr(num2str(age));
list = [name age];
fid=fopen('list.csv','w');
fprintf(fid, '%s\n',list{:,:});
fclose(fid);
The code seen above doesn't make two different columns but a single column. How can I break 'list' into two different column into csv file? Please help me out.
Thank you in advance.

回答 (1 件)

per isakson
per isakson 2013 年 8 月 8 日
This is a more standard approach (without list)
name = {'Jake'; 'Mike'};
age = [24; 22];
fid=fopen('list.csv','w');
for jj = 1 : length( name )
fprintf( fid, '%s,%d\n', name{jj}, age(jj) );
end
fclose(fid);
  1 件のコメント
Jake
Jake 2013 年 8 月 8 日
Thanks a lot!!!!

サインインしてコメントする。

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by