I am trying to do muscle fatigue analysis, what can be done changes in the code.

8 次查看(过去 30 天)
with the following code i a trying to do muscle activation and fatigue analysis base on the fft values.
can someone help me with the code. what am i doing wrong and what changes can be done for the analysis
%% Import Data from TXT files
files = dir('*.txt'); % Returns all the files and folders in the directory
fileTable = struct2table(files);
numOfFiles = height(fileTable);
for k = 1:numOfFiles
if strfind(fileTable.name{k}, 'Fatigue')
secfiles{k} = fileTable.name{k};
end
end
allfiles = secfiles(~cellfun(@isempty,secfiles(:,1)),:);
masterData = struct;
for j = 1:length(allfiles)
file_info(:,j) = split(allfiles(j), "_");
masterData(j).group = file_info(1,j);
masterData(j).muscle = file_info(2,j);
masterData(j).trial = extractBefore(file_info(4,j),'.');
impFatigueA = importdata(allfiles(j));
end
%%
% Fatigue Data
impFatigueA = importdata('Fatigue_A.txt');
impFatigueK = importdata('Fatigue_K.txt');
impFatigueZ = importdata('Fatigue_Z.txt');
%impMVICT2 = importdata('G2_Tricep_MVIC_2.txt');
%% Removing the DC Offset from the Signal %%
impFatigueA2 = detrend(impFatigueA); % detrend removes the mean value or linear trend from a vector or matrix.
impFatigueK2 = detrend(impFatigueK); % detrend removes the mean value or linear trend from a vector or matrix.
impFatigueZ2 = detrend(impFatigueZ);
%% Rectifcication of the Signal
impFatigueA3 = abs(impFatigueA2);
impFatigueK3 = abs(impFatigueK2);
impFatigueZ3 = abs(impFatigueZ2);
%% Creating the Envelope of the EMG Signal %%
[b,a]=butter(5,2.5/1000,'low'); % low pass filter to cut off frequency at 10Hz, using a 5th order filter and a samppling frequencyt of 1000Hz.
impFatigueA4=filtfilt(b,a,impFatigueA3);
impFatigueK4=filtfilt(b,a,impFatigueK3);
impFatigueZ4=filtfilt(b,a,impFatigueZ3);
%% fft plot for impFatigueA4 %%
Fs=1000;
L=length(impFatigueA4);
t=L/Fs;
x=impFatigueA4;
Y = fft(x);
P2 = abs(Y/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = Fs*(0:(L/2))/L;
plot(f,P1)
title('Frequency Spectrum Plot')
xlabel('f (Hz)')
ylabel('|P1(f)|')
Error i am getting.
Index in position 1 exceeds array bounds (must not exceed 3).
Error in untitled (line 17)
masterData(j).trial = extractBefore(file_info(4,j),'.');

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Vibration Analysis 的更多信息

产品


版本

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by