First point smaller than threshold
1 次查看(过去 30 天)
显示 更早的评论
I have written the following code in order to find the first point of an array which is smaller than a threshold and calculate, afterwards, its distance from a certain point:
xfb1 = 7*10^7;
xfb2 = 6*10^7;
for i = 1:length(pks3) %find the point which is the start of QRS
k = pks3(i):-1:length(xfb);
first = k(k<xfb1); % find all k such that k is smaller than xfb1
if ~isempty(first)
first = first(1); %store the first number which is smaller than xfb1
else
disp('No value of k is smaller than xfb1.')
end
numPointsQ = 1:length(locs_RwaveB(i):first);
mean_numPointsQ = mean(numPointsQ);
Qstart = locs_RwaveB(i)*mean_numPointsQ;
end
The data come from electrogram recordings and the problem is that even though a have 250,000 samples in total from a recording, I get a massive amount of points in the end (10^12) which cannot be possible. I think it has to do with the for loop, as I ask it to run 10 times starting from 10 specific pks3 points each time, but for each array k I create I want only one first point to be detected. Could someone please tell me what's wrong with the for loop?
Thanks
0 个评论
回答(1 个)
Steven Lord
2016-5-18
Take a look at the n input described in the documentation for the find function.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!