How can I replace the high pass filter with a Bandpass filter? (New to matlab)

1 回表示 (過去 30 日間)
fontSize = 22;
K = csvread("HeartBeatSample.csv") %path to the sample file
Time = K(1:45465,1);
Voltage= K(1:45465,2); %/amplitude
plot(Time,Voltage) % Plotting the virtual data that given
J = fir1(1000,1/1000*2,'high'); % Smoothing using high pass filter
Voltage_filter = filter(J,1,Voltage);
plot(Voltage_filter)
Findsq = Voltage_filter.^2;
plot(Findsq);
last = 0;
Point = 0;
pulse = zeros(length(Findsq),1);
for L = 1:length(Findsq)
p = 0;
if (Findsq(L) > 0.8)
if (Point == 0)
if (last > 0)
t = L - last;
p = 1000/t*60;
end
last = L;
end
Point = 100;
else
if (Point > 0)
Point = Point - 1;
end
end
pulse(L)=p;
end
plot(pulse); % plotting the pulse graph
grid on;
title('Pulse', 'FontSize', fontSize, 'Interpreter', 'none');
%xlabel('Numbers Of Data');
ylabel('BPM')
title('BPM Graph');
y = pulse;
x = 1 : length(y);
% There are a large number of zeros. Let's set those to nan to ignore them
badIndexes = y <= 0;
% Get rid of those.
x(badIndexes) = [];
y(badIndexes) = [];
% Plot them in red.
hold on;
plot(x, y, 'r-', 'LineWidth', 2);
grid on;
% Find the min and put a line there.
darkGreen = [0, 0.7, 0];
yline(min(y), 'Color', darkGreen, 'LineWidth', 2);
caption = sprintf('Pulse. Min = %f, max = %f', min(y), max(y));
title(caption, 'FontSize', fontSize, 'Interpreter', 'none');
yPrior = rand(1); % Initialize
for L = 1 : length(y)
if ~isnan(y(L)) && y(L) ~= yPrior
if y(L) < 80
fprintf("You're in Normal condition at L = %d with a pulse of %f.\n", x(L), y(L));
elseif y(L) <= 90
fprintf("You're in Stressed condition at L = %d with a pulse of %f.\n", x(L), y(L));
else
fprintf("You're in Critical condition at L = %d with a pulse of %f.\n", x(L), y(L));
end
end
yPrior = y(L);
end
g = gcf;
g.WindowState = 'maximized'
MATLAB Version 9.8 (R2020a)
Simulink Version 10.1 (R2020a)
Control System Toolbox Version 10.8 (R2020a)
DSP System Toolbox Version 9.10 (R2020a)
Data Acquisition Toolbox Version 4.1 (R2020a)
Signal Processing Toolbox Version 8.4 (R2020a)
Statistics and Machine Learning Toolbox Version 11.7 (R2020a)
Symbolic Math Toolbox Version 8.5 (R2020a)

採用された回答

Star Strider
Star Strider 2020 年 9 月 23 日
If you supply the two passband frequencies between 0 and 1 as a vector (frequencies in Hz normalised by the Nyquist frequency), fir1 will automatically design a bandpass filter.
A filter order of 1000 is likely overkill, and will be slow. I would choose a shorter filter (likely less than 200), and use the filtfilt function to do the actual filtering. Use the freqz function to see the filter Bode plot to be certain that ithe filter is doing what you want it to do.
For any EKG, a lower passband of 1 Hz and an upper passband of 100 Hz will pass all the necessary frequencies while eliminating baseline drift and high-frequency noise. In a healthy, normal EKG, an upper passband of 45 Hz will work.
  4 件のコメント
Salinda Nandasena Talapitiya Rallage
Salinda Nandasena Talapitiya Rallage 2020 年 9 月 23 日
Thank you. This improved the the time significally. For some reason using high pass filter does not give the required output.
Star Strider
Star Strider 2020 年 9 月 23 日
As always, my pleasure!
With a cutoff frequency of , the highpass filter would pass essentially everything.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFilter Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by