Please, someone help me to understand this code.

조회 수: 1 (최근 30일)
Mohan Dubey
Mohan Dubey 2021년 5월 9일
댓글: Mohan Dubey 2021년 5월 13일
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,'*');

채택된 답변

Image Analyst
Image Analyst 2021년 5월 9일
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
Image Analyst
Image Analyst 2021년 5월 9일
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 2021년 5월 13일
Thanks a lot. I get it.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by