필터 지우기
필터 지우기

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Filter Analysis에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by