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

1 view (last 30 days)
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!

Accepted Answer

Image Analyst
Image Analyst on 7 Dec 2018
What if you try
sheetName = sprintf('Sheet %d', k);
xlswrite('excel_name.xlsx',stm{k}, sheetName);
  1 Comment
CL
CL on 7 Dec 2018
That worked perfectly for question 1.
Is there a solution for question 2? I believe I will need to convert the numbers into strings before I'm able to strcat the columns into one.

Sign in to comment.

More Answers (0)

Tags

Products


Release

R2016b

Community Treasure Hunt

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

Start Hunting!