How can i change my x-axis to read real time
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Carlos Nunez
am 3 Jul. 2018
Beantwortet: Mridul G
am 3 Jul. 2018
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(t,con);
xlabel('Time(s)');
ylabel('Electrical Activity');
title(sprintf('t=%g[s],BPM= %f',t(end),BPM(end)));
grid on;
drawnow;
end
0 Kommentare
Akzeptierte Antwort
Mridul G
am 3 Jul. 2018
you may consider axis shifting x1, dx y1 y2 constant axis([x1 x1+dx y1 y2]) and apply drawnow after each plot so the graph is updated
The answer to this question may seem to answer your query https://www.mathworks.com/matlabcentral/answers/330234-how-to-make-a-moving-graph-for-a-real-time-signal-along-the-x-axis#answer_259067
0 Kommentare
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!