# the number of elements in the vector segment

3 Ansichten (letzte 30 Tage)
Lev Mihailov am 28 Jul. 2022
Kommentiert: Image Analyst am 28 Jul. 2022
I process the signal with the findpeaks function, it gives the position numbers of these peaks, and now I need to calculate how many peaks are in the time interval.
loc=[2 3 7 8 9 10 25 26 27]
intervaltime=6
%ans= [2 4 0 0 3] % my length vector is 100
%% zeros because there was nothing in the interval 12-18 and 18-24
##### 1 Kommentar-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden
Image Analyst am 28 Jul. 2022
Exactly which elements do you consider below to be "peaks"? And where is your call to findpeaks()?
loc=[2 3 7 8 9 10 25 26 27];
intervaltime=6;
%ans= [2 4 0 0 3] % my length vector is 100
%% zeros because there was nothing in the interval 12-18 and 18-24
plot(loc, 'b.-', 'MarkerSize', 30, 'LineWidth', 2);
grid on;
title('Peak Detection');
xlabel('Index')
ylabel('loc Signal Value')

Melden Sie sich an, um zu kommentieren.

### Antworten (1)

Mathias Smeets am 28 Jul. 2022
Probably not the best way to go but I got this:
location = [ 2 3 7 8 9 10 25 26 27];
intervaltime = 6;
for i = 1:5
result(i) = length(location(location < i*6));
result(i) = result(i) - length(location(location < (i-1)*6))
end
result = 2
result = 1×2
2 4
result = 1×3
2 4 0
result = 1×4
2 4 0 0
result = 1×5
2 4 0 0 3
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Descriptive Statistics finden Sie in Help Center und File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by