필터 지우기
필터 지우기

How to resolve the error "Conversion to cell from double is not possible"

조회 수: 2 (최근 30일)
Neha Sinha
Neha Sinha 2023년 1월 24일
답변: Nehemiae 2023년 3월 7일
% Load the ECG data
load('ecg_values.mat');
% Define the filter window size
window_size = 1000;
filter_order = 2;
low_cutoff = 0.1; % Hz
high_cutoff = 100; % Hz
% Define the number of ECG signals
num_signals = 5;
% Initialize a matrix to store the filtered signals
ecg_filt = zeros(size(ecg_values));
for i = 1:num_signals
% Read the ECG signal from the .mat file
ecg = ecg_values(i,:);
fs = 300;
% Remove baseline wander using a median filter
ecg_filt(i,:) = medfilt1(ecg, window_size);
%Removing wander and noise using butter worth filter
[b,a] = butter(filter_order, low_cutoff/(fs/2), 'low');
ecg_filta(i,:) = filtfilt(b, a, ecg);
[b,a] = butter(filter_order, high_cutoff/(fs/2), 'low');
ecg_filtw(i,:) = filtfilt(b, a, ecg);
% Plot the original and filtered ECG signals
figure;
subplot(4,1,1);
plot(ecg);
title(strcat("Original ECG Signal ",num2str(i)));
subplot(4,1,2);
plot(ecg_filt(i,:));
title(strcat("Filtered ECG Signal ",num2str(i)));
subplot(4,1,3);
plot(ecg_filta(i,:));
title(strcat("Filtered ECG Signal low noise",num2str(i)));
subplot(4,1,4);
plot(ecg_filtw(i,:));
title(strcat("Filtered ECG Signal high noise",num2str(i)));
end
% Save the filtered signals in a new .mat file
%save("result.mat","ecg_filt","ecg_fs");
I have attached my code as above

답변 (1개)

Nehemiae
Nehemiae 2023년 3월 7일
Hello,
Upon running the code with the provided MAT file, I got the following graphs as output with no errors in R2022b. If you could confirm the version of MATLAB you are using, it would help in narrowing down the issue.
The documentation on “version” (https://www.mathworks.com/help/matlab/ref/version.html) in getting the installed version details, if you are unsure about it.

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by