i want to save cell data as csv format ,but il shows there is a error,how can i save these cell array as csv format? thanks

조회 수: 4 (최근 30일)
S =
{ 19x2 cell}
{ 3x2 cell}
{ 1x2 cell}
{ 10x2 cell}
{ 1x2 cell}
[]
[]
{ 6x2 cell}
{ 210x2 cell}
[]
{ 13041x2 cell}
{ 15x2 cell}
{ 91x2 cell}
[]
{ 6x2 cell}
{ 1x2 cell}
{ 1x2 cell}
{ 66x2 cell}
{ 1x2 cell}
{ 496x2 cell}
[]
{ 66x2 cell}
S{1}=ans =
'4400002970000003533' '8500000190000013093'
'4400002970000003533' '8500000190000045501'
'4400002970000003533' '8500000840000005660'
'4400002970000003533' '8500000840000006008'
'4400002970000003533' '8500090100000000354'
'4400002970000003533' '8500090100000007316'
'4400002970000003533' '8500090100000009112'
'4400002970000003533' '8500090100000010547'
'8500000190000013093' '8500000190000045501'
'8500000190000013093' '8500000840000005660'
'8500000190000013093' '8500000840000006008'
'8500000190000013093' '8500090100000000354'
'8500000190000013093' '8500090100000007316'
'8500000190000013093' '8500090100000009112'
'8500000190000013093' '8500090100000010547'
'8500000190000045501' '8500000840000005660'
'8500000190000045501' '8500000840000006008'
'8500000190000045501' '8500090100000000354'
'8500000190000045501' '8500090100000007316'
I use csvwrite('lpc.csv',S),but it doesn't work and il always shows a error, anyone can help me ? thanks

답변 (3개)

Orion
Orion 2014년 10월 13일
Hi,
The problem is that you have a cell inside a cell, so you can't write it in a csvfile. it will mean that you create a text file in a text file, which is a nonsense.
with your example, you can use csvwrite as
csvwrite('lpc.csv',S{1}) % only the first cell of your cell.
if you need to save all the informations inside the cell S, you should consider creating a loop like
for i = 1:length(S)
csvwrite(sprintf('lpc_S%d.csv',i),S{i});
end
and so each csv file will contain the ith cell of the original cell S.
  댓글 수: 1
pengcheng
pengcheng 2014년 10월 13일
편집: pengcheng 2014년 10월 13일
if length(S)=1000,S is saved by 1000 csv fiche,like lpc_S1, lpc_S2, lpc_S3....,can i get a csv file that contains all of them?

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


Sean de Wolski
Sean de Wolski 2014년 10월 13일

per isakson
per isakson 2014년 10월 13일
The function Cell Array to CSV-file by Jerry might write your cell array to a "csv" file.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by