Write a cell array to a .csv file

조회 수: 48 (최근 30일)
Damith
Damith 2014년 11월 25일
답변: Walter Roberson 2022년 1월 14일
Hi,
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.
csvwrite('110416.csv',newdata(:,1:2));
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.

답변 (3개)

Geoff Hayes
Geoff Hayes 2014년 11월 25일
Damith - see Export Cell Array to Text File which uses fprintf to write each row of your cell array to file.
  댓글 수: 4
Damith
Damith 2014년 11월 25일
Thanks. This works.
Akhil Narayanan
Akhil Narayanan 2022년 1월 14일
thanks

댓글을 달려면 로그인하십시오.


Walter Roberson
Walter Roberson 2022년 1월 14일
These days, use writecell()

D. benoy
D. benoy 2014년 11월 26일
Hi,
If you have EXCEL on your computer you can do the following instead
xlswrite('110416.xls',y);
Open 110416.xls and save it as a csv file.
  댓글 수: 3
Preston Dial
Preston Dial 2018년 7월 25일
I am getting the same error from the xlswrite function for one of my projects
Devansh Deepak Patel
Devansh Deepak Patel 2020년 8월 12일
me too

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by