trouble displaying my BPM on the title graph when running the code can someone show me how to do this

조회 수: 3 (최근 30일)
clear all
a= arduino('COM3','Uno')
interv=200;
time=1
x=2.0
last=0;
upflag=0;
while(time<interv)
b=readVoltage(a,'A0');
x=[x,b];
time=time+1;
plot(x,'ro-')
xlabel('Samples');
ylabel('Electrical Activity');
title(sprintf('time=%g[s],BPM= %f',time(end)));
grid on;
hold on;
drawnow
%highpass filtering
h=fir1(interv,1/interv*2,'high');
x_filter=filter(h,1,b );
plot(x_filter);
hold on
%squaring the singal
detsq=x_filter.^2;
plot(detsq);
pulse=zeros(length(detsq),1);
for i=length(detsq)
if(detsq(i)>3)
if(upflag)==0
if ( last>0)
interv=200;
time= i-last;
p= interv/time*60
pulse(i)=p;
end
last = i;
end
upflag=100;
else
if (upflag >0)
upflag=upflag-1;
end
end
end
end

답변 (0개)

카테고리

Help CenterFile Exchange에서 Arduino Hardware에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by