-
Notifications
You must be signed in to change notification settings - Fork 2
/
PlotDistanceRun.m
26 lines (22 loc) · 1.09 KB
/
PlotDistanceRun.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
% Import csv file
[fileName,pathName] = uigetfile('*.csv','Select CSV file');
delimiter = ',';
startRow = 2;
formatSpec = '%f%f%[^\n\r]';
fileID = fopen(fullfile(pathName,fileName),'r');
dataArray = textscan(fileID, formatSpec, 'Delimiter', delimiter, 'TextType', 'string', 'EmptyValue', NaN, 'HeaderLines' ,startRow-1, 'ReturnOnError', false, 'EndOfLine', '\r\n');
fclose(fileID);
runData = table(dataArray{1:end-1}, 'VariableNames', {'Value','TimestampTimeOfDayTotalMilliseconds'});
clearvars filename delimiter startRow formatSpec fileID dataArray ans;
% Adjust values
runData.Value=runData.Value-runData.Value(1);
runData.TimestampTimeOfDayTotalMilliseconds=runData.TimestampTimeOfDayTotalMilliseconds-runData.TimestampTimeOfDayTotalMilliseconds(1);
%Plot
folderName=regexp(pathName,['(?<=\' filesep ')\w+' '(?=\' filesep '$)'],'once','match');
figTitle=[folderName ' wheel training'];
figure('name',figTitle);
plot(runData.TimestampTimeOfDayTotalMilliseconds/60000,runData.Value*0.03,...
'k','Linewidth',2); %3cm off wheel center
title({figTitle;'Distance run'})
xlabel('Time (mn)')
ylabel('Distance (m)')