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

1 Ansicht (letzte 30 Tage)
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

Antworten (3)

Orion
Orion am 13 Okt. 2014
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 Kommentar
pengcheng
pengcheng am 13 Okt. 2014
Bearbeitet: pengcheng am 13 Okt. 2014
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?

Melden Sie sich an, um zu kommentieren.


Sean de Wolski
Sean de Wolski am 13 Okt. 2014

per isakson
per isakson am 13 Okt. 2014
The function Cell Array to CSV-file by Jerry might write your cell array to a "csv" file.

Kategorien

Mehr zu Variables 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!

Translated by