I have written a script that calculates the average time between certain experimental events across all trials for a given participant. I would now like to create an excel spreadsheet that compiles this information for all the different participant files. It would contain 4 columns:
- the participant's file number (as a string),
- the average time between events #1 and #2,
- the average time between events #2 and #3,
- and the difference in the number of occurrences of events #3 and #4.
Each row will therefore be representative of an individual file, and you can append a row every time you run a new file. Here is my attempt below;
%... ^script that creates all the variables and whatnot
outputTable=table(VarNameStr,Screen_Grasp_Average,Grasp_Release_Average,difference); %these are the four variables I am trying to output
writetable(outputTable,D:\LocationName\DataLocation\Spreadsheet.xlsx);
What I am trying to do here is append these four different variables as a row to the excel spreadsheet 'Spreadsheet' located at D:\LocationName\DataLocation using writetable(). This has given me the error that the '\' is an invalid operator . I think I have two main issues facing me and one smaller issue;
- How to specify the location of the spreadsheet that I want to output to? It seems writetable doesn't have this ability. Should the script I am running and the spreadsheet be in the same folder? Or can they be separate?
- I want to be sure that I am appending to the spreadsheet, not overwriting anything.
- (smaller) How can I prevent repeat lines? I want to prevent the same file from being analyzed and outputted more than once since other lab members will be using this script as well. Worst comes to worst I could just use unique() when reading the file in matlab but I was curious if there was a better way.
Thanks for any answers/help!
Best Answer