MATLAB: Trying to get MATLAB to export multiple files on to different sheets

MATLABxlswrite

Hi everyone,
1) I'm trying to xlswrite all of the 'stm{k}' vectors onto Excel with each vector on a different sheet but, it seems to only export the first vector multiple times.
2) I would like to string the columns prior to exporting 'stm{k}' onto Excel. Right now, it's splitting 'H H : M M : S S . f f f' into seperate columns . I'm trying to get them all into one cell 'HH:MM:SS.fff' (on Excel it's the concatenate function for joining together strings).
folder='X';
filetype='*.xlsx';
f = fullfile(folder,filetype);
d = dir(f);
% Read all excel files in folder
for k=1:numel(d)
de{k}=xlsread(fullfile(folder,d(k).name),'D:D');
stm{k} = datestr(seconds(de{k}),'HH:MM:SS.fff'); % Convert seconds into time format
% Output as Excel
for sheet=1:numel(d)
xlswrite('excel_name',stm{k},sheet);
end
end
Thank you!

Best Answer

What if you try
sheetName = sprintf('Sheet %d', k);
xlswrite('excel_name.xlsx',stm{k}, sheetName);