MATLAB: I save a cellarry ,but the result looks like strange

save a cellarry

S{1}
ans =
'4400002970000003533' '8500000190000013093'
'4400002970000003533' '8500000190000045501'
'4400002970000003533' '8500000840000005660'
'4400002970000003533' '8500000840000006008'
csvwrite('s1.csv',S{1}); but when i open the file , the result is like this 4,4,0,0,0,0,2,9,7,0,0,0,0,0,0,3,5,3,3,8,5,0,0,0,0,0,1,9,0,0,0,0,0,1,3,0,9,3 4,4,0,0,0,0,2,9,7,0,0,0,0,0,0,3,5,3,3,8,5,0,0,0,0,0,1,9,0,0,0,0,0,4,5,5,0,1 4,4,0,0,0,0,2,9,7,0,0,0,0,0,0,3,5,3,3,8,5,0,0,0,0,0,8,4,0,0,0,0,0,0,5,6,6,0 4,4,0,0,0,0,2,9,7,0,0,0,0,0,0,3,5,3,3,8,5,0,0,0,0,0,8,4,0,0,0,0,0,0,6,0,0,8 do you konw why? can you help me? thanks

Best Answer

Remember that your strings are just arrays of characters. So when you export the array to file using csvwrite, a comma will be inserted between each element in the array - so a comma between each character.
You may want to consider an alternative method to export cell array data to a text file. From this example, you could do
% open the file
fid = fopen('s1.csv','wt+');
if fid>0
% write each row to file
V = S{1}; % assumes that V is a cell array
for k=1:size(V,1)
fprintf(fid,'%s,%s\n',V{k,:});
end
fclose(fid);
end
Now, when you open the s1.csv file, you will see
4400002970000003533,8500000190000013093
4400002970000003533,8500000190000045501
4400002970000003533,8500000840000005660
4400002970000003533,8500000840000006008
which is probably what you would like.