
How to resolve the error "Conversion to cell from double is not possible"
조회 수: 3 (최근 30일)
이전 댓글 표시
% 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

Link for ecg_values.mat file : https://drive.google.com/file/d/1BSUuKQkARgd2PHPoXZPMAw2Iaanf7JbX/view?usp=share_link
댓글 수: 0
답변 (1개)
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.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Single-Rate Filters에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!