Help creating RMS Window
Hello,
I am supposed to import data from 10 Excel files then filter, rectify and create a RMS window for the data, but I am stuck at the last step. I am not very good at MATLAB, but I believe that I am on the right track so far. Any help would be extremely appreciated. I included what I have so far; the commented section at the end is what I am supposed to work off of. I tried a similar loop like the ones prior but did not succeed. Thank you in advance!
clear all; clc
fileName ={‘Gait_normal01.csv’;’Gait_normal02.csv’;’Gait_rightlimp01.csv’;’Gait_rightlimp02.csv’;’MVC_Extension01.csv’;…
‘MVC_Extension02.csv’;’MVC_Flexion01.csv’;’MVC_Flexion02.csv’;’SitStand01.csv’;’Squat01.csv’}
% read in Data
for i=1:10
EMGraw_data{i,1} =dlmread(fileName{i,1},’,’,5,2);
end
%filter
for i=1:10
i
for j=1:4
j
[B,A]=butter(2,[10/500 350/500],’bandpass’);
EMGf{i,1}(:,j) = filtfilt(B,A,EMGraw_data{i,1}(:,j));
end
end
% rectify
for i=1:10
i
for j=1:4
j
EMGrec{i,1}(:,j) = abs(EMGf{i,1}(:,j));
end
end
% %Root mean square
% winlength = 299; %input 1-desired window length
% EMGrms=zeros(length(EMGrec)-winlength,1);
% for i=1:length(EMGrec)-winlength;
% win=EMGrec(i:i+winlength);
% EMGrms(i+(winlength+1)/2)=sqrt(sum(win.^2)/winlength);
% endHello,
I am supposed to import data from 10 Excel files then filter, rectify and create a RMS window for the data, but I am stuck at the last step. I am not very good at MATLAB, but I believe that I am on the right track so far. Any help would be extremely appreciated. I included what I have so far; the commented section at the end is what I am supposed to work off of. I tried a similar loop like the ones prior but did not succeed. Thank you in advance!
clear all; clc
fileName ={‘Gait_normal01.csv’;’Gait_normal02.csv’;’Gait_rightlimp01.csv’;’Gait_rightlimp02.csv’;’MVC_Extension01.csv’;…
‘MVC_Extension02.csv’;’MVC_Flexion01.csv’;’MVC_Flexion02.csv’;’SitStand01.csv’;’Squat01.csv’}
% read in Data
for i=1:10
EMGraw_data{i,1} =dlmread(fileName{i,1},’,’,5,2);
end
%filter
for i=1:10
i
for j=1:4
j
[B,A]=butter(2,[10/500 350/500],’bandpass’);
EMGf{i,1}(:,j) = filtfilt(B,A,EMGraw_data{i,1}(:,j));
end
end
% rectify
for i=1:10
i
for j=1:4
j
EMGrec{i,1}(:,j) = abs(EMGf{i,1}(:,j));
end
end
% %Root mean square
% winlength = 299; %input 1-desired window length
% EMGrms=zeros(length(EMGrec)-winlength,1);
% for i=1:length(EMGrec)-winlength;
% win=EMGrec(i:i+winlength);
% EMGrms(i+(winlength+1)/2)=sqrt(sum(win.^2)/winlength);
% end Hello,
I am supposed to import data from 10 Excel files then filter, rectify and create a RMS window for the data, but I am stuck at the last step. I am not very good at MATLAB, but I believe that I am on the right track so far. Any help would be extremely appreciated. I included what I have so far; the commented section at the end is what I am supposed to work off of. I tried a similar loop like the ones prior but did not succeed. Thank you in advance!
clear all; clc
fileName ={‘Gait_normal01.csv’;’Gait_normal02.csv’;’Gait_rightlimp01.csv’;’Gait_rightlimp02.csv’;’MVC_Extension01.csv’;…
‘MVC_Extension02.csv’;’MVC_Flexion01.csv’;’MVC_Flexion02.csv’;’SitStand01.csv’;’Squat01.csv’}
% read in Data
for i=1:10
EMGraw_data{i,1} =dlmread(fileName{i,1},’,’,5,2);
end
%filter
for i=1:10
i
for j=1:4
j
[B,A]=butter(2,[10/500 350/500],’bandpass’);
EMGf{i,1}(:,j) = filtfilt(B,A,EMGraw_data{i,1}(:,j));
end
end
% rectify
for i=1:10
i
for j=1:4
j
EMGrec{i,1}(:,j) = abs(EMGf{i,1}(:,j));
end
end
% %Root mean square
% winlength = 299; %input 1-desired window length
% EMGrms=zeros(length(EMGrec)-winlength,1);
% for i=1:length(EMGrec)-winlength;
% win=EMGrec(i:i+winlength);
% EMGrms(i+(winlength+1)/2)=sqrt(sum(win.^2)/winlength);
% end rms, for, loop, for loop, win, winlength, root, mean, square MATLAB Answers — New Questions