| | | |
%SpineAcc: | Calculates the human response of the spine, alx, aly and alz, and also Dx, Dy and Dz, |
% | from acceleration measurements in the seat. |
%path: | Directory in which the measurement files are located. |
%xfile, yfile, or zfile: ASCII file with a time vector in the first column and the measurement result in the x-, y- or |
% | z-direction, asx, asy, or asz, in the second column. |
%lf any of the filenames is given as an empty string ", calculations will not be performed in that direction. |
| |
%subfunction calls |
if xfile ~" | |
figure(1) | |
clf | |
SpineAccXY(path, xfile, 'x'); |
end | |
if yfile ~" | |
figure(2) | |
clf | |
SpineAccXY(path, yfile, 'y'); |
end | |
if zfile ~" | |
figure(3) | |
clf | |
SpineAccZ(path, zfile); |
end | |
function SpineAccXY(path, file, XorY) |
| |
%SpineAccXY: % | Calculates the human response of the spine, alx, aly, Dx and Dy from acceleration measurements in the seat. The result is stored in the file_al.txt, along with the time |
vector. | |
%load input file | |
as=load([path, file, ' .txt']); | |
|
%separation of input time data measurement data |
time=as(:,1); | |
as=as(:,2); | |
| |
%calculation of al(t) |
a=[1, -1.957115,0.963949]; |
b=[0.0192752,0.00433451, -0.0167763]; |
a1=filter(b, a, as); |
|
%call the function CountPeaks to cakculate Dk |
Dk=CountPeaks(a1, XorY); |
|
%plot the result |
plot (time, a1) |
title (file) |
legend(['D', XorY,' = ', 2str(Dk)], 1) |
|
%add the time column to the calculated response and the calculated value Dk to the last row and second |
%column |
a1=[time, a1; 0 Dk]; |
eval (['save', path, file, '_al.txt a1 -ascii-tabs']) |
|
function SpineAccZ (path, zfile) |
| |
%SpineAccZ: | Calculates the human response of the spine, alz and Dz from acceleration measurements in |
% | the seat. The result is stored in the file zfile_al.txt, along with the time vector. |
%path: | Directory in which measurement files are located. |
%zfile: | ASCII file with a time vector in the first column and the measurement result, asz, in the |
% | second column. |
| |
%load input file |
asz=load ([path, zfile,' .txt']); |
([' save', path,file,' _al.txt alz -ascii -tabs']) |
|
%separation of input time data and measurement data |
time=asz(:, 1); |
asz=asz(:, 2); |
|
%extension of asz with 8 samples |
asz=[0; 0; 0; 0; 0; 0; 0; 0; asz]; |
|
%preallocation of memory |
alz=zeros (size (asz)); |
x=zeros (length (asz), 7); |
|
%constants |
w=[0.00130 0.01841 -0.00336 0.01471 0.00174 0.00137 0.00145; |
-0.00646 -0.00565 -0.00539 0.01544 -0.00542 0.00381 0.00497; |
-0.00091 0.02073 0.00708 -0.00091 0.00255 -0.00216 0.01001; |
0.00898 -0.02626 0.00438 -0.00595 -0.00774 -0.00034 0.01283; |
0.00201 0.00579 0.00330 -0.00065 -0.00459 -0.00417 -0.00468; |
0.00158 0.00859 0.00166 0.00490 -0.00546 0.00057 -0.00797; |
0.00361 0.00490 0.00452 0.00079 -0.00604 -0.00638 -0.00529; |
0.00167 -0.00098 0.00743 0.00795 -0.01095 0.00627 -0.00341; |
-0.00078 -0.00261 0.00771 0.00600 -0.00908 0.00504 0.00135; |
-0.00405 -0.00210 0.00520 0.00176 -0.00465 -0.00198 0.00451; |
0.00563 0.00218 -0.00105 0.00195 0.00296 -0.00190 0.00306; |
-0.00372 0.00037 -0.00045 -0.00197 0.00289 -0.00448 0.00216; |
-0.31088 -0.95883 -0.67105 0.14423 0.04063 0.07029 1.0330]; |
|
w= [57.96539 52.32773 49.78227 53.1688556. 02619 -27.79550 72.34446, 21.51959]; |
|
%calculation of alz(t) |
for t = (9:1ength(asz)); |
for j=1 : 7 |
x(t, j) = sum(alz (t-1: -1: t-4). *w(1:4, j))+sum (asz(t-1: -1: t-8). *w(5:12, j)) |
+w(13, j); |
x(t, j)=tanh(x(t, j)); |
end |
alz(t)=sum(W(1:7). *x(t, 1:7))+W(8); |
end |
alz=alz(9:1ength (asz)); |
|
%call the function CountPeaks to calculate Dz |
Dz=CouhtPeaks (alz,' z'); |
|
%plot the result in figure 3 |
plot (time, alz) |
title (zfile) |
legend ([' Dz = ', 2str(Dz)], 1) |
|
%add the time column to the calculated response and the calculated value Dz to the last row and second |
%column |
alz= [time, alz; 0 Dz); |
(['save', path, zfile, '_al. txt alz -ascii -tabs']) |
|
function Dk=CountPeaks (alk, xyz) |
|
%CountPeaks: | Calculates Dk from the input signal alk. |
%Dk: | Calculated output value Dk. |
%alk: | Input vector: One column with the response alk. |
%xyz: | String expression: 'x', 'y' or 'z' depending on which direction the input vector represents. |
| |
Dk=0; |
i=1; |
id1=1; |
id2=1; |
|
%set the array pointers id1 and id2 each time signal changes sign (+/-) and find the maximum between id1 and |
%id2 |
for i=1 : 1ength (alk) -1 |
if (((alk (i)>0)&(alk (i+1)<0)) | ((alk (i)<0) & (alk (i+1)>0))) |
id2=i; |
if alk (id2) <0 |
[mx, ind]=min((alk (id1 : id2))); |
if((xyz==' z ')|(xyz==' Z ')) |
mx=0; |
end |
else |
[mx, ind] =max ((alk (id1 : id2))); |
end |
Dk=Dk+mx6; |
id1=id2; |
end |
end |
Dk=Dk(1/6) |
якорь