generate a for loop that will get the peak to peak amplitude of m-wave in matlab

Assuming you have loaded the signals into variables t and m_wave, you can use the following code to generate a for loop that calculates the peak to peak amplitude:

main.m
n = length(m_wave);
amp = zeros(n, 1);

for i = 1:n
    y = m_wave(t >= t(i)-0.4 & t <= t(i)+1.4);
    amp(i) = max(y) - min(y);
end
133 chars
8 lines

This loops through each sample point in the m_wave signal, selects a window of 0.4 seconds before and 1.4 seconds after the sample point (t denotes the time points), and calculates the peak-to-peak amplitude of the signal within that window. The amplitudes are stored in the amp variable.

Note that the specific window size used here (0.4 seconds before, 1.4 seconds after) is just an example and may need to be adjusted based on the characteristics of your signal.

related categories

gistlibby LogSnag