MATLAB Answers

export a cell array with same size matrices to excel

1 view (last 30 days)
I have a 1x23 cell with matrices inside:
30x30 double 30x30 double 30x30 double ...
How to export this cell array with matrices on excel? I want each 30x30 matrix a seperate sheet so I will have 23 sheets for the cell array.

Accepted Answer

fred  ssemwogerere
fred ssemwogerere on 12 Feb 2020
Hello, something like this should do nicely:
% Taking "C" to be your cell array, and your excel file as: "myfile.xlsx"
for k=1:size(C,2)
xlswrite('myfile.xlsx',C{k},'Sheet',k);
end
  2 Comments
fred  ssemwogerere
fred ssemwogerere on 12 Feb 2020
Hello, sorry my mistake. Change the code to this:
% Taking "C" to be your cell array, and your excel file as: "myfile.xlsx"
for k=1:size(C,2)
xlswrite('myfile.xlsx',C{k},k); % I have removed the string "Sheet".
end

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!