Change the matlab file name to include the date in the filename

This commit is contained in:
Thomas Dehaeze 2019-05-13 22:35:37 +02:00
parent 7ae17e7a60
commit 299c7336df

View File

@ -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');