How to write multiple heterogeneous vectors data stored in a 1 row cell array into a csv file?
2 ビュー (過去 30 日間)
古いコメントを表示
I have a cell array MyCellArray= {[1,2], [1,2,3,4], [1,2,3], [0,999, 1]}; I want to get the data in a csv file organized as the following:
1 1 1 0
2 2 2 999
3 3 1
4
How to do that?
0 件のコメント
回答 (1 件)
Prannay Jain
2016 年 11 月 14 日
csvwrite(filename,M) does not accept cell arrays for the input matrix M. However, you could use 'xlswrite' as shown below and save the .xls file to .csv file.
>> xlswrite('xlsexample.xls',c{1}.','Sheet1','A1');
>> xlswrite('xlsexample.xls',c{2}.','Sheet1','B1');
>> xlswrite('xlsexample.xls',c{3}.','Sheet1','C1');
>> xlswrite('xlsexample.xls',c{4}.','Sheet1','D1');
I am assuming you would like to save c{1} which is a row vector into 'A1' cell of Excel as a column vector, hence I am using the transpose of c{1} = c{1}.' in 'xlswrite'.
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!