clear
load("DataSets\clustering_data.mat");
load("DataSets\withExoEMG.mat");
load("DataSets\withoutExoEMG.mat");
% load("DataSets\maxEMGVals.mat");
fr = 1000;
nq_freq = fr/2;
cutoff_low = 10;
cutoff_high = 150;
max_emg_vals = struct;
[b,a] = butter(4,[cutoff_low,cutoff_high]/nq_freq,"bandpass");
exp_names = emg_without_exo_data.keys();
channels_muscles=["Right deltoid", "Right Biceps", "Left Deltoid", "Left Biceps"];
for i=1:length(exp_names)
exp_names{i}
emg_exp_data = emg_without_exo_data(exp_names{i});
clust_data = clustering_without_exo(exp_names{i});
valid_indexes = find((clust_data.ids==2));
recorted_data = struct;
channels_data = emg_exp_data.ch_data;
WinLen = 4000; % Window Length For RMS Calculation
index=1;
step=400;
fieldnames_emg = fieldnames(channels_data);
for j=1:length(fieldnames_emg)
ch_name = fieldnames_emg{j};
ch_data = channels_data.(ch_name);
figure(2*i -1)
subplot(4,1,j)
plot(ch_data(1,:)*0.001, ch_data(2,:))
ylim([-1.6e-3, 1.6e-3]);
xlabel("time (s)")
ylabel("Sensor signal (V)")
title(strcat("Sensor output ",channels_muscles(j)))
f = fr*(0:length(ch_data(2,:))/2)/length(ch_data(2,:));
four = fft(ch_data(2,:));
four = abs(four/length(four));
four = four(1:(length(four)/2+1));
four(2:end-1) = 2*four(2:end-1);
figure(2*i)
subplot(4,1,j)
plot(f, four)
xlabel("Frequency Hz")
ylabel("|fft|")
title(strcat("Fourier transform ",channels_muscles(j)," data"))
ch_data(2,:) = filtfilt(b,a, ch_data(2,:));
if (isfield(max_emg_vals, ch_name)==false)
max_emg_vals.(ch_name) = 0;
end
max_emg_vals.(ch_name) = max(max_emg_vals.(ch_name), max(ch_data(2,:)));
% ch_data(2,:) = ch_data(2,:)./max_emg_vals.(ch_name);
emg_indexes = round(ch_data(1,:)/10);
recorted_data.(ch_name).recorted = ch_data(2, ismember(emg_indexes, valid_indexes));
end
emg_without_exo_data(exp_names{i}).recorted = recorted_data;
end
exp_names = emg_with_exo_data.keys();
for i=1:length(exp_names)
exp_data = emg_with_exo_data(exp_names{i});
clust_data = clustering_with_exo(exp_names{i});
valid_indexes = find((clust_data.ids==2));
recorted_data = struct;
channels_data = emg_exp_data.ch_data;
WinLen = 4000; % Window Length For RMS Calculation
index=1;
step=400;
fieldnames_emg = fieldnames(channels_data);
figure
for j=1:length(fieldnames_emg)
ch_name = fieldnames_emg{j};
ch_data = channels_data.(ch_name);
figure(2*(i+3) -1)
subplot(4,1,j)
plot(ch_data(1,:)*0.001, ch_data(2,:))
ylim([-1.6e-3, 1.6e-3]);
xlabel("time (s)")
ylabel("Sensor signal (V)")
title(strcat("Sensor output ",channels_muscles(j)))
f = fr*(0:length(ch_data(2,:))/2)/length(ch_data(2,:));
four = fft(ch_data(2,:));
four = abs(four/length(four));
four = four(1:(length(four)/2+1));
four(2:end-1) = 2*four(2:end-1);
figure(2*(i+3))
subplot(4,1,j)
plot(f, four)
xlabel("Frequency Hz")
ylabel("|fft|")
title(strcat("Fourier transform ",channels_muscles(j)," data"))
ch_data(2,:) = filtfilt(b,a, ch_data(2,:));
if (isfield(max_emg_vals, ch_name)==false)
max_emg_vals.(ch_name) = 0;
end
max_emg_vals.(ch_name) = max(max_emg_vals.(ch_name), max(ch_data(2,:)));
% ch_data(2,:) = ch_data(2,:)./max_emg_vals.(ch_name);
emg_indexes = round(ch_data(1,:)/10);
recorted_data.(ch_name).recorted = ch_data(2, ismember(emg_indexes, valid_indexes));
end
emg_with_exo_data(exp_names{i}).recorted = recorted_data;
end
%%
exp_names = emg_without_exo_data.keys();
for i=1:length(exp_names)
exp_names{i}
emg_exp_data = emg_without_exo_data(exp_names{i});
clust_data = clustering_without_exo(exp_names{i});
valid_indexes = find((clust_data.ids==2));
recorted_data = struct;
channels_data = emg_exp_data.ch_data;
WinLen = 4000; % Window Length For RMS Calculation
index=1;
step=400;
fieldnames_emg = fieldnames(channels_data);
for j=1:length(fieldnames_emg)
ch_name = fieldnames_emg{j};
ch_data = channels_data.(ch_name);
ch_data(2,:) = filtfilt(b,a, ch_data(2,:));
ch_data(2,:) = ch_data(2,:)./max_emg_vals.(ch_name);
emg_indexes = round(ch_data(1,:)/10);
recorted_data.(ch_name).recorted = ch_data(2, ismember(emg_indexes, valid_indexes));
window_indexes = 1:step:length(recorted_data.(ch_name).recorted)-WinLen;
rmsv = zeros(1, length(window_indexes));
arvv = zeros(1, length(window_indexes));
md_freq = zeros(1, length(window_indexes));
mean_freq = zeros(1, length(window_indexes));
index=1;
for k=window_indexes
signal_cutted = recorted_data.(ch_name).recorted(k:k+WinLen);
rmsv(index) = rms(signal_cutted,2);
arvv(index) = sum(abs(signal_cutted),2)/WinLen;
md_freq(index) = medfreq(signal_cutted,fr);
mean_freq(index) = meanfreq(signal_cutted,fr);
index=index+1;
end
recorted_data.(ch_name).rmsv = rmsv;
recorted_data.(ch_name).arvv = arvv;
recorted_data.(ch_name).md_freq = md_freq;
recorted_data.(ch_name).mean_freq = mean_freq;
figure(15)
subplot(4,1,j)
hold on
plot(rmsv)
ylim([0.05, 0.22])
figure(16)
subplot(4,1,j)
hold on
plot(arvv)
ylim([0.05, 0.22])
figure(17)
subplot(4,1,j)
hold on
plot(md_freq)
ylim([40, 65])
figure(18)
subplot(4,1,j)
hold on
plot(mean_freq)
ylim([40, 65])
end
emg_without_exo_data(exp_names{i}).recorted = recorted_data;
end
exp_names = emg_with_exo_data.keys();
for i=1:length(exp_names)
exp_data = emg_with_exo_data(exp_names{i});
clust_data = clustering_with_exo(exp_names{i});
valid_indexes = find((clust_data.ids==2));
recorted_data = struct;
channels_data = emg_exp_data.ch_data;
WinLen = 4000; % Window Length For RMS Calculation
index=1;
step=400;
fieldnames_emg = fieldnames(channels_data);
for j=1:length(fieldnames_emg)
ch_name = fieldnames_emg{j};
ch_data = channels_data.(ch_name);
ch_data(2,:) = filtfilt(b,a, ch_data(2,:));
ch_data(2,:) = ch_data(2,:)./max_emg_vals.(ch_name);
emg_indexes = round(ch_data(1,:)/10);
recorted_data.(ch_name).recorted = ch_data(2, ismember(emg_indexes, valid_indexes));
window_indexes = 1:step:length(recorted_data.(ch_name).recorted)-WinLen;
rmsv = zeros(1, length(window_indexes));
arvv = zeros(1, length(window_indexes));
md_freq = zeros(1, length(window_indexes));
mean_freq = zeros(1, length(window_indexes));
index=1;
for k=window_indexes
signal_cutted = recorted_data.(ch_name).recorted(k:k+WinLen);
rmsv(index) = rms(signal_cutted,2);
arvv(index) = sum(abs(signal_cutted),2)/WinLen;
md_freq(index) = medfreq(signal_cutted,fr);
mean_freq(index) = meanfreq(signal_cutted,fr);
index=index+1;
end
recorted_data.(ch_name).rmsv = rmsv(1:750);
recorted_data.(ch_name).arvv = arvv(1:750);
recorted_data.(ch_name).md_freq = md_freq(1:750);
recorted_data.(ch_name).mean_freq = mean_freq(1:750);
figure(19)
subplot(4,1,j)
hold on
plot(rmsv(1:850))
ylim([0.
没有合适的资源?快使用搜索试试~ 我知道了~
使用FREEEMG系统和MVN系统的SDK获得的EMG和惯性数据的matlab代码.zip
共14个文件
m:13个
asv:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 143 浏览量
2024-02-21
23:25:23
上传
评论
收藏 21KB ZIP 举报
温馨提示
1.版本:matlab2014/2019a/2021a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。
资源推荐
资源详情
资源评论
收起资源包目录
使用FREEEMG系统和MVN系统的SDK获得的EMG和惯性数据的matlab代码.zip (14个子文件)
使用FREEEMG系统和MVN系统的SDK获得的EMG和惯性数据的matlab代码
matlab_code-main
UnifyCharsXSens.m 960B
ObtainEMGData.m 1KB
ClusteringCombined.m 4KB
XSensFourierTranform.m 9KB
ObtainXsensData.m 1KB
XSensDataAnalisys.asv 3KB
CreateDBXSens.m 8KB
Deltoids_data_analysis.m 9KB
XSensClustering.m 1KB
XSensPreprocess.m 6KB
XSensDataAnalisys.m 3KB
EMGDataAnalysys.m 7KB
Bicep_delt_data_analisys.m 14KB
data_analisys.m 5KB
共 14 条
- 1
资源评论
Matlab科研辅导帮
- 粉丝: 1w+
- 资源: 7553
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功