How can I acquire the last number of points in my beats per count. The code right now is able to read the entire history of data points and I only want the last points
조회 수: 2 (최근 30일)
이전 댓글 표시
clear all; a= arduino('COM3','Uno')
x=[]; t=[]; Fv=50; BPM=0; order=8 tic; for k=1:1000 toc; b=readVoltage(a,'A0'); x=[x,b]; t=[t;toc]; delta_t=diff(t);% Gave me the average of delta t tf=mean(delta_t)% Gave me the mean for the delta t fs=1./tf % Frequency %This will plot the samples of raw data that the pusle sensor is %reading into Matlab. It will display the graph of the raw data and %extract the data points in order to convert to ECG(heart single
%Low pass filter
cutt_off=[8/Fv/2]; % the 8 represents the lowest number of frequncy the
%code is runnin at
h=fir1(order,cutt_off);
con=conv(x,h);
beat_count=0; for k=2:length(con)-1 %This lets Matlab know what I'm looking for in the peaks if( con(k)> con(k-1) & con(k)> con(k+1) & con(k)>1); beat_count = beat_count + 1; end N = length(con); duration_in_seconds = N./fs; duration_in_mintues= duration_in_seconds/60; BPM = beat_count./duration_in_mintues;
end
figure(1)
plot(con);
xlabel('Time(s)');
ylabel('Electrical Activity');
title(sprintf('t=%g[s],BPM= %f',t(end),BPM(end)));
grid on;
drawnow;
end
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Arduino Hardware에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!