フィルターのクリア

Apply a filter to a dataset of ecg signals

15 ビュー (過去 30 日間)
Sabaudian
Sabaudian 2022 年 6 月 17 日
コメント済み: Sabaudian 2022 年 6 月 17 日
I have a dataset of 48 ECG signals (attached here as a zip file, but I use it unzipped), placed in a directory. I have use a for-cicle to load all the signal in the workspace, but now I am a bit confunsed.
I want to apply to the signals a Band-Pass Butterworth filter, so I use butter to design the filter and filtfilt to apply it. But I have a problem with size in "y(i)". This is the error I get:
"Unable to perform assignment because the indices on the left side are not compatible
with the size of the right side."
this is my code:
Fs = 360; % sample frequency of signals [Hz]
files = dir(fullfile("dataset/","*.mat"));
for i = 1:numel(files)
data(i) = load(files(i).name); % load signals
[b,a] = butter(3,[1 30]/(Fs/2),"bandpass"); % bandpass butterworth filter of third order with 1-30 Hz
y(i) = filtfilt(b,a,data(i).val); % apply the filter to all signals
end

採用された回答

Karim
Karim 2022 年 6 月 17 日
Hello, the problem is that you didn't initalize the variable "y". Hence you are trying to fit an array of 1x3600 into a single position (i.e. y(i) ).
See below for a quick fix:
files = dir(fullfile("dataset/","*.mat"));
Fs = 360; % sample frequency of signals [Hz]
[b,a] = butter(3,[1 30]/(Fs/2),"bandpass"); % bandpass butterworth filter of third order with 1-30 Hz
y = zeros(numel(files), 3600);
for i = 1:numel(files)
data(i) = load(fullfile("dataset/",files(i).name)); % load signals
y(i,:) = filtfilt(b,a,data(i).val); % apply the filter to all signals
end
  1 件のコメント
Sabaudian
Sabaudian 2022 年 6 月 17 日
thank you

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by