-
Notifications
You must be signed in to change notification settings - Fork 0
/
runtrial.m
94 lines (82 loc) · 3.13 KB
/
runtrial.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
% For loading all processed data, running SPG model, and getting predicted results
% from the model
clear all
close all
trial=[16,17,19]; % trial no.
BW=92*9.81; %body weight
for c=1 %:10; %; % condition of subject for which to run analysis [1:5]
t = 1; % counter in loop
for tr = 1:3 %trial no.
eval(['load pp',num2str(c),'/tr',num2str(trial(tr))]); % load data
disp(['pp',num2str(c),'/tr',num2str(trial(tr))]); % display data
eval(['F_R' num2str(trial(tr)) '= Force_R(:,1);']);
eval(['F_L' num2str(trial(tr)) '= Force_L(:,1);']);
eval(['HA_R' num2str(trial(tr)) '= HA_R;']);
eval(['HA_L' num2str(trial(tr)) '= HA_L;']);
eval(['filter_y_RTA' num2str(trial(tr)) '= filter_y_RTA;']);
eval(['filter_y_RSO' num2str(trial(tr)) '= filter_y_RSO;']);
eval(['filter_y_LTA' num2str(trial(tr)) '= filter_y_LTA;']);
eval(['filter_y_LSO' num2str(trial(tr)) '= filter_y_LSO;']);
t = t + 1;
end;
end;
a = input('which side? R - 1, L - 2 ');
if a == 1;
eval(['Force=[F_R' num2str(trial(tr-2)) '; F_R' num2str(trial(tr-1)) '; F_R' num2str(trial(tr)) ']/BW;';]); % Force. normalised.
eval(['HA=([HA_R' num2str(trial(tr-2)) '; HA_R' num2str(trial(tr-1)) '; HA_R' num2str(trial(tr)) ']*pi)/180;';]); % hip angle. convert to radians.
N=length(Force);
x1 = linspace(0,4.9999e-004*N,N)';
data2=[x1 Force HA];
eval([ 'data2(:,4)=[filter_y_RSO' num2str(trial(tr-2)) '; filter_y_RSO' num2str(trial(tr-1)) '; filter_y_RSO' num2str(trial(tr)) '];' ]);
eval([ 'data2(:,5)=[filter_y_RTA' num2str(trial(tr-2)) '; filter_y_RTA' num2str(trial(tr-1)) '; filter_y_RTA' num2str(trial(tr)) '];' ]);
else
eval(['Force=[F_L' num2str(trial(tr-2)) '; F_L' num2str(trial(tr-1)) '; F_L' num2str(trial(tr)) ']/BW;';]); % Force. normalised.
eval(['HA=([HA_L' num2str(trial(tr-2)) '; HA_L' num2str(trial(tr-1)) '; HA_L' num2str(trial(tr)) ']*pi)/180;';]); % hip angle. convert to radians.
N=length(Force);
x1 = linspace(0,4.9999e-004*N,N)';
data2=[x1 Force HA];
eval([ 'data2(:,4)=[filter_y_LSO' num2str(trial(tr-2)) '; filter_y_LSO' num2str(trial(tr-1)) '; filter_y_LSO' num2str(trial(tr)) '];' ]);
eval([ 'data2(:,5)=[filter_y_LTA' num2str(trial(tr-2)) '; filter_y_LTA' num2str(trial(tr-1)) '; filter_y_LTA' num2str(trial(tr)) '];' ]);
end;
disp(sum(isnan(data2)))
%% initial parameters
w1=0.16;
w2=0.27;
wv1=0.12;
wv2=0.37;
wa3=-1.64;
wa4=-4.49;
wva3=98.76;
wva4=284.60;
r1=2.2952;
r2=0.0054;
a11=12.64;
a12=-10.35;
Ta1=0.090;
Ta2=0.061;
b1=14.88;
b2=46.03;
%
para0(1)=w1;
para0(2)=w2;
para0(3)=wv1;
para0(4)=wv2;
para0(5)=wa3;
para0(6)=wa4;
para0(7)=wva3;
para0(8)=wva4;
para0(9)=r1;
para0(10)=r2;
para0(11)=a11;
para0(12)=a12;
para0(13)=Ta1;
para0(14)=Ta2;
para0(15)=b1;
para0(16)=b2;
%% spg
daten={data2};
para_point=1:16;
[cf_,gof,out] = spgfit(daten, para0, para_point);
parameter=coeffvalues(cf_)
cf=[gof.rmse gof.sse]
simplot(daten, parameter);