Write a cell array to a .csv file

211 views (last 30 days)
Damith on 25 Nov 2014
Answered: Walter Roberson on 14 Jan 2022
I have a cell array "newdata" as shown below.
'01/01/2001' 0
'02/01/2001' 0
'03/01/2001' 0
'04/01/2001' 0
'05/01/2001' 14.1000000000000
'06/01/2001' 0
'07/01/2001' 0
I need to write this to a .csv file. So, I used the following code to do that.
But, I got the following error.
Error using dlmwrite (line 112)
The input cell array cannot be converted to a matrix.
Error in csvwrite (line 42)
dlmwrite(filename, m, ',', r, c);
Can somebody suggest me a different way or how to correct this.?
Thanks in advance.

Answers (3)

Geoff Hayes
Geoff Hayes on 25 Nov 2014
Damith - see Export Cell Array to Text File which uses fprintf to write each row of your cell array to file.

Sign in to comment.

Walter Roberson
Walter Roberson on 14 Jan 2022
These days, use writecell()

D. benoy
D. benoy on 26 Nov 2014
If you have EXCEL on your computer you can do the following instead
Open 110416.xls and save it as a csv file.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!