-->inct = 0.05; -->N = 10000; -->mup = - 0.2 * (sin(%pi*[0:127]/128).^4) .* (sin(2*%pi*[0:127]/128)); -->discharges = [ 4300 7500]; -->rate = zeros(1,N); -->rate(discharges)=1; -->emg = convol (rate, mup); -->emg = emg(1:N);Now we are going to contaminate the signal with noise
-->rand('normal') -->rand('seed',0) -->emgnoise = emg + 0.08*rand(emg);The process of extraction implies the use of a template with the shape that we want to detect. In our case, to detect the shape of the `motor unit potential' we use a template which contains the original form. In correlation, both signals must have the same length. To get the correlation of `mup' with `emgnoise' we have to pad the signal with `zeros'. We call `mup2' the shape of the `motor unit potential' padded with zeros.
-->mup2 = [mup, zeros(1,N-length(mup))]; -->correl = corr (mup2,emgnoise,N);Now we can plot the result
-->xsetech([0,0,1,1/3]) -->plot2d ((1:N)*inct,emg); -->xsetech([0,1/3,1,1/3]) -->plot2d((1:N)*inct,emgnoise); -->xsetech([0,2/3,1,1/3]) -->plot2d((1:N)*inct,correl)And the result is
Do you get the idea? If we have a template we can locate this shape in the signal even in a noisy environment.