MATLAB: Calculate the overlap to validate model

anybodyoverlap

Hi
I have two different curves which shows the muscle activity in a crank cycle which have been resampled to 360 – one for each degree. One of them is collected from EMG recording and the other have been extracted from at model in Anybody, and is being used calculate the overlap when the muscle is active at different thresholds. The two different curves have been changed so that everything below the maximum peak times 0.25 is 0 (inactive) and everything above is 1 (active). Now I want to calculate the overlap and figure out, in percentage, when is both of them 1 (active)?
Thanks in advance

Best Answer

I created two signals to experiment with this. The code is straightforward:
t = linspace(0, 100, 1000);
EMG = sin(2*pi*t/20) .* cos(2*pi*t/50) + 1;
AB = sin(2*pi*t/25 + 0.2) .* cos(2*pi*t/40) + 1;
EMGT = 1*(EMG > 0.25) + 0*(EMG <= 0.25);
ABT = 1*(AB > 0.25) + 0*(AB <= 0.25);
Active = EMGT .* ABT;
ActivePct = 100 * sum(Active)/numel(Active);
figure(1)
subplot(3,1,1)
plot(t, EMG, '-b')
hold on
plot(t, AB, '-r')
hold off
legend('EMG', 'Model')
grid
subplot(3,1,2)
plot(t, EMGT, '-c')
hold on
plot(t, ABT, '-m')
hold off
axis([xlim -0.1 1.1])
legend('EMG', 'Model')
grid
subplot(3,1,3)
plot(t, Active, '-g', 'LineWidth',2)
axis([xlim -0.1 1.5])
text(mean(t), 1.25, sprintf('Percent Both Active = %.2f', ActivePct), 'HorizontalAlignment','center', 'VerticalAlignment','middle')
grid
Experiment to get the result you want.