Please, someone help me to understand this code.

1 vue (au cours des 30 derniers jours)
Mohan Dubey
Mohan Dubey le 9 Mai 2021
Commenté : Mohan Dubey le 13 Mai 2021
I'm a beginner in MATLAB and i have to understand this code as it's important for my project. I request you guys to please help me to understand this code.
ec=xlsread('sumit_ecg.xlsx','B3:B1000003');
figure;
plot(ec);
j=1;
for i=2:length(ec)-1;
if ec(i-1)< ec(i) && ec(i+1)<ec(i);
ecgy1(j)=ec(i);
ecgx1(j)=i;
j=j+1;
end
end
figure;plot(ec); hold on;
plot(ecgx1,ecgy1,'*');
j=j+1;
for i=1:length(ecgy1);
if ecgy1(i)>=2;
ecgy2(j)=ecgy1(i);
ecgx2(j)=ecgx1(i);
j=j+1;
end
end
figure;plot(ec); hold on;
plot(ecgx2,ecgy2,'*');

Réponse acceptée

Image Analyst
Image Analyst le 9 Mai 2021
It would be easier if you'd attach your workbook, but it looks like it's doing some kind of peak detection where if an element is more than the prior one and subsequent one (so it's a local max), it logs/records the value of that local maximum.
Then it plots it and records where the peaks have a value of more than 2 and then plots those.
  4 commentaires
Image Analyst
Image Analyst le 9 Mai 2021
if ec(i-1)< ec(i) && ec(i+1)<ec(i);
basically sees if the i'th element is more than the elements on either side of it.
j is a counter so that the ecgx1 and ecgy1 only have the peak values and none of the values in between.
ecgy1(j)=ec(i);
ecgx1(j)=i;
The first line records the y value of the j'th peak. The second line records the index that the j'th peak occurred at.
Mohan Dubey
Mohan Dubey le 13 Mai 2021
Thanks a lot. I get it.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by