Exporting cell arrays with different sizes to excel

I have a cell array A with size [1x2], which contains two different arrays [1x4 double] and [1x5 double]. I need to have the different arrays in A in Excel, with the first array on A1 and the second array on A2. However, the only thing I managed to get is to get both arrays behind each other in A1, using B=cell2mat(A), and then xlswrite(filename,B).
How do I get the first array on A1 and the second array on A2?
Thanks in advance!

 Accepted Answer

Do this:
xlswrite(filename,A{1},'1','A1');
xlswrite(filename,A{2},'1','A2');

3 Comments

Thanks, this seems to work. However, how can I use this for a [1xk] cell array, where I would like the n'th array to be written on A(n)?
Try this:
for k=1:n
xlswrite(filename,A{k},'1',['A' , int2str([k])]);
end
Yes, works like a charm! Thanks a lot

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!