-
Notifications
You must be signed in to change notification settings - Fork 0
/
pltexc_emg.m
executable file
·165 lines (132 loc) · 3.72 KB
/
pltexc_emg.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
% This draws a figure of emg patterns and block-excitation timing
clear all;
close all;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
load W60emgave.txt; %experimental emg data
emg=W60emgave;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[row,col]=size(emg); %the first column is index, then ave and sd for sol,gas,bflf,ta,rf,vas,gas in this order
x_axis=emg(:,1); % gait cycle index
nmus=7; %7 emg data
nmusG=15;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%normalize emg
for i=1:nmus
max_amp(i)=max(emg(:,2*i));
emg(:,2*i)=emg(:,2*i)/max_amp(i);
end
%%add vas2 and vas3 (for plotting purpose)
emg_add(:,1)=emg(:,2); %sol
emg_add(:,2)=emg(:,4); %gas
emg_add(:,3)=emg(:,6); %ham
emg_add(:,4)=emg(:,8); %ta
emg_add(:,5)=emg(:,10); %rf
emg_add(:,6)=emg(:,12); %vas
emg_add(:,7)=emg(:,12); %vas
emg_add(:,8)=emg(:,12); %vas
emg_add(:,9)=emg(:,14); %gmax
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% add simulation excitation patterns to the plots
load SAoptEMG.dat;
data=SAoptEMG;
% %% spline
% for j=1:101
% x1(j)=data(j,29);
% vas1(j)=data(j,30);
% x2(j)=data(j,33);
% vas2(j)=data(j,34);
% x3(j)=data(j,37);
% vas3(j)=data(j,38);
% end
% xspace=linspace(0,100,101);
%
% vas1spline=spline(x1,vas1,xspace);
% vas2spline=spline(x2,vas2,xspace);
% vas3spline=spline(x3,vas3,xspace);
%
% for j=1:101
% if vas1spline(j)<0
% vas1spline(j)=0;
% end
%
% if vas2spline(j)<0
% vas2spline(j)=0;
% end
%
% if vas2spline(j)<0
% vas3spline(j)=0;
% end
% end
%
% %%take average
% for j=1:101
% avevas(j)=(vas1spline(j)+vas2spline(j)+vas3spline(j))/3.0;
% end
xaxis=1:101;
% rearrange data
exc=[data(:,1),data(:,2),...%solG
data(:,5),data(:,6),...%gasG
data(:,9),data(:,10),...%hamG
data(:,21),data(:,22), ...%taG
data(:,25),data(:,26),...rfG
data(:,29),data(:,30),...vas1G
data(:,81),data(:,82),...vas2G
data(:,85),data(:,86),...vas3G
data(:,33),data(:,34),...gmaxG
data(:,13),data(:,14),...%bfshG
data(:,17),data(:,18),...%psoasG
data(:,37),data(:,38),...%gmedG
data(:,41), data(:,42),... %perlngG
data(:,49), data(:,50),... %flxdigG
data(:,73), data(:,74)]; %extdigG
% Normalize muscle excitations
%normalize emg
for i=1:nmusG
max_exc(i)=max(exc(:,2*i));
norm_exc(:,2*i)=exc(:,2*i)/max_exc(i);
end
j=1;
figure(1);
set(gcf,'Position',[140 40 640 650]);
orient tall;
curve_name=str2mat('SOL','MGAS','BF','TA','RF','VAS1','VAS2','VAS3','GMAX','BFsh','PSOAS','GMED','PERLNG','FLXDIG','EXTDIG');
for nfig=1:nmusG
hold on;
subplot(4,4,nfig),plot(exc(:,j),exc(:,j+1),'r');
j=j+2;
hold on;
%**** General formats
axis ('normal');
set(gca,'LineWidth',2.0);
H1=get(gca,'Children');
set(H1,'LineWidth',2.0);
set(gca,'FontSize',12,'FontName','Arial', 'FontWeight','bold');
set(gca,'XLim',[0 100])
set(gca,'YLim',[0 1])
set(gca,'XTick',[0 50 100]')
set(gca,'XTickLabel',[ ]');
grid off;
box off;
%****************************************************************
title(curve_name(nfig,:));
if (nfig==12 | nfig==13 | nfig==14 | nfig==15)
xlabel('% Gait Cycle');
set(gca,'XTickLabel',[0 50 100]')
end
if(nfig==13)
ylabel('% Max');
end
end
%plot emg pattern
xplot=0:100;
n=1;
for i=1:nmus+2
subplot(4,4,n)
hold on;
%plot(x_axis,emg(:,2*i),'g');
plot(x_axis,emg_add(:,i),'g');
n=n+1;
set(gca,'LineWidth',2.0);
H1=get(gca,'Children');
set(H1,'LineWidth',2.0);
end