Filter löschen
Filter löschen

First point smaller than threshold

1 Ansicht (letzte 30 Tage)
Konstantinos
Konstantinos am 18 Mai 2016
Kommentiert: Konstantinos am 18 Mai 2016
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

Antworten (1)

Steven Lord
Steven Lord am 18 Mai 2016
Take a look at the n input described in the documentation for the find function.
  1 Kommentar
Konstantinos
Konstantinos am 18 Mai 2016
I'm sorry but that's not helpful enough for my case. Thanks though for the answer.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by