How to resolve the error "Conversion to cell from double is not possible"
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
% 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 commentaires
Réponses (1)
Nehemiae
le 7 Mar 2023
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 commentaires
Voir également
Catégories
En savoir plus sur Single-Rate Filters dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!