-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgetEposData.m
More file actions
38 lines (28 loc) · 1.84 KB
/
getEposData.m
File metadata and controls
38 lines (28 loc) · 1.84 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
function [recordedData, samplingPeriod, expEndTime, counts, velocityAvg, torqueAvg, velocity, torque] = ...
getEposData(dirName, fileName, motorNominalTorque)
[~,~,rawData] = xlsread(fullfile(dirName, fileName));
rawData = rawData(:,1);
index = find(contains(rawData,'ms'));
recordedDataLine = index - 1;
numericDataStart = index + 1;
% samplesNo = str2double(cell2mat(regexp(rawData{7}, '\d*', 'Match')));
samplingPeriod = str2double(cell2mat(regexp(rawData{8}, '\d*', 'Match')))/10^6;
recordedData = strsplit(rawData{recordedDataLine}, ';');
recordedDataNo = numel(recordedData);
responseData = zeros(length(rawData(numericDataStart:end)), recordedDataNo);
for i = 1:length(rawData(numericDataStart:end))
responseData(i,:) = (str2num(rawData{numericDataStart - 1 + i})');
end
countsIdx = find(strcmpi(recordedData, 'position actual value') == 1, 1);
torqueAveragedIdx = find(strcmpi(recordedData, 'torque actual value averaged') == 1, 1);
velocityAveragedIdx = find(strcmpi(recordedData, 'velocity actual value averaged') == 1, 1);
velocityIdx = find(strcmpi(recordedData, 'velocity actual value') == 1, 1);
torqueIdx = find(strcmpi(recordedData, 'torque actual value') == 1, 1);
time = (0:samplingPeriod:(length(rawData(numericDataStart:end))-1)*samplingPeriod)'; % sec
expEndTime = max(time); % sec
counts = timeseries(-responseData(:,countsIdx), time);
velocityAvg = timeseries(-responseData(:,velocityAveragedIdx)*pi/30, time); % rad/s
torqueAvg = timeseries(-responseData(:,torqueAveragedIdx)*motorNominalTorque/100, time); % Nm
velocity = timeseries(-responseData(:,velocityIdx)*pi/30, time); % rad/s
torque = timeseries(-responseData(:,torqueIdx)*motorNominalTorque/100, time); % Nm
end