Create a new excel file from trimmed data

5 ビュー (過去 30 日間)
alexandra ligeti
alexandra ligeti 2022 年 10 月 4 日
コメント済み: alexandra ligeti 2022 年 10 月 7 日
Hi there,
I have data of different activities. Each activity is repeted three times. Previously in the code the activities and the respctive three trials of data are manipulated. Once I have finished manipulating the data I wish to save the new version of the activity data in a new folder called TimeSyncData.
I have managed to achieve this, however, the three trials of the activity land up saving in the same excel file but different sheets. Is there a way of saving the different activity trials in different files rather than having them in one file but in different sheets as it is making it difficult to work with.
%% Folder where the time synchronised data will be saved
OutputFolderName = 'TimeSyncData';
if ~exist(OutputFolderName, 'dir')
mkdir(OutputFolderName);
end
cd(OutputFolderName)
%creating an excel file with the new time synchronised data contained,
%different sheets are the different trials
for i = 1:sz
T = struct2table(trimmed_sync(i));
writetable(T,strcat(activity,'.xls'),'Sheet',"Trial "+i);
end
As seen below activity T04A has three trials but saved in three sheets within the same file. I wish to have three seperate excel files T04A, T04A_1, T04A_2 for the different trials instead.
Any advice would be hugely appreciated. If more code is needed to understand what is being asked please let me know.
Thanks,
Lexi

採用された回答

dpb
dpb 2022 年 10 月 4 日
移動済み: dpb 2022 年 10 月 4 日
Shure...just build a file name dynamically somehow instead of incrementing the sheet number as you did.
FILES={'T04A', 'T04A_1', 'T04A_2'};
...
...
for i = 1:sz
T = struct2table(trimmed_sync(i));
writetable(T,fullfile(OutputFolderName,strcat(FILES(i),'.xls')),'Sheet','PickASheetNameHere');
end
  3 件のコメント
dpb
dpb 2022 年 10 月 5 日
Show your code; how did you define the OutputFolderName -- it must be the target directory to which you want to write the file....
Make sure the output of the call to fullfile is a valid filename...set a breakpoint in the debugger and check...
alexandra ligeti
alexandra ligeti 2022 年 10 月 7 日
Hi, I was able to fix the error.
Thank you very much for the help.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by