How to write multiple heterogeneous vectors data stored in a 1 row cell array into a csv file?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Prannay Jain
am 14 Nov. 2016
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 Kommentare
Siehe auch
Kategorien
Mehr zu Spreadsheets finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!