calculate the peak to peak amplitude of both an m-wave and h-reflex in a 600 data point by 21 trial matrix emg signal in matlab

Assuming that each row of the matrix corresponds to a different trial and each column corresponds to a different data point in time, first you need to identify the time window for the m-wave and h-reflex.

Once you have identified the time windows, you can extract the relevant data points for each trial using MATLAB's indexing capabilities. Then, for each trial, you can calculate the peak-to-peak amplitude of the m-wave and h-reflex by finding the maximum and minimum values within the respective time window and taking their difference.

Here's an example MATLAB code that assumes the time window for the m-wave is from data points 50 to 75, and the time window for the h-reflex is from data points 100 to 125:

main.m
%Example data matrix
emg_matrix = rand(21,600);

%Define time windows
mw_start = 50;
mw_end = 75;
hr_start = 100;
hr_end = 125;

%Preallocate arrays to store results
mw_amplitude = zeros(21,1);
hr_amplitude = zeros(21,1);

%Loop through each trial
for i = 1:21
    %Extract m-wave data points for current trial
    mw_data = emg_matrix(i,mw_start:mw_end);
    %Calculate peak-to-peak amplitude of m-wave
    mw_amplitude(i) = max(mw_data) - min(mw_data);
    
    %Extract h-reflex data points for current trial
    hr_data = emg_matrix(i,hr_start:hr_end);
    %Calculate peak-to-peak amplitude of h-reflex
    hr_amplitude(i) = max(hr_data) - min(hr_data);
end

%Print results
disp("M-wave peak-to-peak amplitudes:");
disp(mw_amplitude);
disp("H-reflex peak-to-peak amplitudes:");
disp(hr_amplitude);
802 chars
32 lines

This code should result in two arrays, mw_amplitude and hr_amplitude, which contain the peak-to-peak amplitudes of the m-wave and h-reflex for each of the 21 trials.

related categories

gistlibby LogSnag