MATLAB: How to write elements of a nested cell array to an excel

nested cell array to excel

Hi all,
I have nested cell array where each cell array contains a time series.
How do I write the contents of each of the cell array into rows in excel in the same sheet?
Like for example i want WS {2,1} to be written to the 2nd row in excel in the same sheet.
Capture.PNG

Best Answer

for old version of MATLAB
n = cellfun(@numel,WC);
k = cumsum(n);
ii = k - n + 1;
v = ones(k(end),1);
v(ii(2:end)) = v(ii(2:end)) - n(1:end-1);
A = accumarray([repelem((1:numel(n))',n),cumsum(v)],[C{:}]',[],[],nan);
xlswrite('yourxlsxfile.xlsx',A);