Borrar filtros
Borrar filtros

How to write multiple heterogeneous vectors data stored in a 1 row cell array into a csv file?

3 visualizaciones (últimos 30 días)
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?

Respuestas (1)

Prannay Jain
Prannay Jain el 14 de Nov. de 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'.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by