I have a bunch of files in a folder, with names that look like this:
I have a code that automatically updates the file using regexprep, amongst other things. right now, the code chooses the file with user input, for instances:
root = 'E:\MATLAB';
user_input_squad = input('please enter squad number: ', 's');
user_input_experiment = input('please enter experiment name: ', 's');
user_input_stage = input('please enter stage: ', 's');
user_input_session = input('Please enter session: ', 's');
file = fullfile(root, sprintf('squad%s_1910_EXP%s_St1_Se%s', user_input_squad, user_input_experiment, user_input_session));
Is there a way for matlab to pull the last file added, without the need for user input? something that sorts the directory by date, and chooses the first one?
this would have to be for a bunch of files, as they change periodically. for instance, there would be 2 files named
the squad number is the only chnage to the name. so if a user inputs squad 2, is there a way to automatically pick only the latest squad 2 file, without touching the others?