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 回表示 (過去 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 Center および File ExchangeData Import from MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by