From 299c7336dfd0ea81e9a76b77588e236eb19e4dcf Mon Sep 17 00:00:00 2001 From: Thomas Dehaeze Date: Mon, 13 May 2019 22:35:37 +0200 Subject: [PATCH] Change the matlab file name to include the date in the filename --- speedgoat-measurement/run_test.m | 41 +++++++++++++++----------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/speedgoat-measurement/run_test.m b/speedgoat-measurement/run_test.m index 91741d3..1bb85ab 100644 --- a/speedgoat-measurement/run_test.m +++ b/speedgoat-measurement/run_test.m @@ -19,35 +19,32 @@ if tg.Connected == "Yes" if tg.Status == "stopped" disp('Load the Application'); tg.load('measure_channels'); + %% Get the current date for the filename + % Get the current date and time + date_str = erase(cellstr(num2str(clock')), ' '); + % Don't take the seconds and add some "_" + date_str = strjoin(date_str(1:5), '_'); %% Run the application disp('Starting the Application'); tg.start; pause(Tsim); tg.stop; + + %% Get the data from the speedgoat + f = SimulinkRealTime.openFTP(tg); + cd(f, 'data/measure_channels/'); + mget(f, 'data_001.dat', 'data'); + close(f); + + % Convert the data to a Matlab object + data = SimulinkRealTime.utils.getFileScopeData('data/data_001.dat').data; + + %% Save the new data into one mat file + save(['mat/data_', date_str, '.mat'], 'data'); + else + error("The target computer is running"); end else error("The target computer is not connected"); end - -%% -f = SimulinkRealTime.openFTP(tg); -cd(f, 'data/measure_channels/'); -mget(f, 'data_001.dat', 'data'); -close(f); - -data = SimulinkRealTime.utils.getFileScopeData('data/data_001.dat').data; - -%% -n = 52; - -while isfile(['mat/data_', num2str(n, '%03d'), '.mat']) - disp('File exists.'); - if input(['Are you sure you want to override the file ', 'mat/data_', ... - num2str(n, '%03d'), '.mat', ' ? [Y/n]']) == 'Y' - break; - end - n = input('What should be the measurement number?'); -end - -save(['mat/data_', num2str(n, '%03d'), '.mat'], 'data');