Export cell array xlswrite

1 view (last 30 days)
Ali N
Ali N on 21 Jan 2020
Answered: Jakob B. Nielsen on 21 Jan 2020
Hello all
I have cell arrey, each cell has a different dimention. I just want to Exports these cells one after another in a Excel file. Is there anyway to do that witha single line code or a loop. I can not do this with a single xlswrite.
Thanks

Accepted Answer

Jakob B. Nielsen
Jakob B. Nielsen on 21 Jan 2020
Looping is the way to go. Depending on the dimensions of your cell you need to modify this, but for an example cell array named X with 2 cells, the first a 1x4 and the next a 1x7;
for i=1:size(X,2)
range=strcat('A',num2str(i),':A',num2str(i)); %write from excel cell A1 on the first run, A2 next run etc.
xlswrite(X{i,1},)
end
If some cells in your cell array are 2D, you will need to adjust accordingly. Note for this specific example your cells need to be rows - if they are columns, simply put a ' next to it.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!