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 Center および File ExchangeDescriptive Statistics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by