cannot run the code because unknown about getMemberNames function
2 views (last 30 days)
Show older comments
Dear all,
This is the answer of my professor about the ECG detection, but I cant run that code. Anyone know how to fix this, please help me
clc;
close all;
clear all;
load ecg_sbj1
load ecg_sbj2
load ecg_sbj3
load ecg_sbj4
nms = getMemberNames(heartrates);
for k = 1:heartrates.NumMembers
v = getLabelValues(heartrates,k,["QRSregions" "Rpeaks"]);
hr = diff(cellfun(@(x) x.Location,v));
subplot(2,1,k)
histogram(hr,0.5:0.025:1.5)
legend("hrv = " + std(hr))
ylabel(nms(k))
ylim([0 6])
end
function [labelVals,labelLocs] = findQRS(x,t,parentLabelVal,parentLabelLoc,varargin)
labelVals = cell(2,1);
labelLocs = cell(2,1);
if nargin<5
Fs = 250;
else
Fs = varargin{1};
end
df = 20;
load("trainedQTSegmentationNetwork","net")
for kj = 1:size(x,2)
sig = x(:,kj);
mitFSST = computeFSST(sig,Fs);
netPreds = classify(net,mitFSST,MiniBatchSize==50);
QRS = categorical([netPreds{1} netPreds{2}]',"QRS");
msk = signalMask(QRS,MinLength==df,SampleRate==Fs);
r = roimask(msk);
labelVals{kj} = r.Value;
labelLocs{kj} = r.ROILimits;
end
labelVals = vertcat(labelVals{:});
labelLocs = cell2mat(labelLocs);
end
0 Comments
Answers (1)
Cris LaPierre
on 21 Mar 2022
You need the Signal Processing Toolbox in order to use getMemberNames. If it is included on your license, you can use theAdd-ons Explorer to add it.
However, once added, you will find that you do not have a variable names heartrates.
2 Comments
Cris LaPierre
on 21 Mar 2022
I cannot create the variable for you. You must have code somewhere that does that already.
Each mat file of yours contains 2 variables - ecg and Fs. By loading them back to back the way you are doing, you will only be able to access the data in ecg_sbj4, as it overwrites all the others.
You may need to go back to your professor for more details.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!