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

回答(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 中查找有关 Single-Rate Filters 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by