Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

I want to know how can I acquire the last N points of a falling peak after my ECG signal is being produced. Right now I am able to acquire the peaks of the whole system but I only want the last n points

1 visualización (últimos 30 días)
a= arduino('COM3','Uno') x=[]; % We need to establish an initial start t=[];% We need to establish an initial time fv=4% (hertz) In order for the low pass filter to work I must have a higher frequency so it is within the range of the pass band
%Low pass filter order=8;%assign a number of order to smooth out the low pass filter graph cutt_off=0.5/fv/2; % the 8 represents the lowest number of frequncy the %code is runnin at h=fir1(order,cutt_off); %it can start from 20 and up but to be safe I decided to start at 30 BPM=0;
tic; for k=1:300 % Number of iteration points toc; b=readVoltage(a,'A0'); % allows Matlab to read analog input x=[x,b]; t=[t;toc]; delta_t=diff(t);% Gaves 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
con=conv(x,h);% so that the function is between the noise signal and the low pass filter
beat_count=0;
for v=2:length(con)-1
%This lets Matlab know what I'm looking for in the peaks
if( con(v)> con(v-1) & con(v)> con(v+1) & con(v)>1);
beat_count = beat_count + 1
end
N = length(con); % this will gather the last N points duration_in_seconds = N./fs; duration_in_mintues= duration_in_seconds/60; BPM = beat_count./duration_in_mintues;
end
%Created two plots to show the difference that the low pass filter does % and to show that I can plot real time data on the x-axis
%The low pass filter subplot(2,1,1) plot(con,'ro-') xlabel('samples'); ylabel('Electrical Activity'); title(sprintf('t=%g[s],BPM= %f',t(end),BPM(end))); grid; drawnow; % Data without low pass filter subplot(2,1,2) plot(t,x) xlabel('Time(s)'); ylabel('Electrical Activity'); title(sprintf('t=%g[s],BPM= %f',t(end),BPM(end))); grid; drawnow;
end

Respuestas (0)

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by