How to ignore peaks and find the x-axis location of the others?

4 views (last 30 days)
Hello,
I am analysing jumping tests (Counter Movement Jump) with data from a marker based motion capture camera system. The test person is doing three jumps in a row. To find the maximum height of the highest jump is not the problem, but I also need the force distribution at the lowest point from the same jump.
My problem is to find the right minimas for that and just the one with the highest jump: I need erverytime the maxima after the great minima. Is there a chance to ignore the first peak and start with the second? Or to specify findpeaks to only search after the minima? (My data is different in every test person, so just start at an other frame wouldn't work for all data)
And is it possible to just locate the one after the highest jump?
The code is below.
%% Static
% Static height
Z_Static = PZ;
Static_H = mean(Z_Static); % height of the marker in mm
%% Counter Movement Jump
Z_CMJ = PZ1;
F_CMJ = Frame1;
figure
plot(Z_CMJ);
findpeaks(Z_CMJ, "MinPeakProminence",100, "MaxPeakWidth", 100);
% all jumping heights
H_Z_CMJ_ges = findpeaks(Z_CMJ, "MinPeakProminence", 100, "MaxPeakWidth", 100);
% max position marker
max_H_CMJ = max(H_Z_CMJ_ges);
% jumping height of max jump in cm
Sprung_H_CMJ = (max_H_CMJ - Static_H)/10
% lowest point after landing (squat)
min_CMJ = Z_CMJ *-1;
figure
plot(min_CMJ);
findpeaks(min_CMJ, 'MinPeakProminence', 100, 'MaxPeakWidth',100, 'MinPeakDistance',500);
And the data is attached.
I imported the .txt files as Column Vectors with the import function and only use 'Frames' and 'PZ' of each file. First the static file and then the CMJ_ges.
Thank you!

Accepted Answer

Star Strider
Star Strider on 11 Jul 2022
I am not exactly certain what you want, however selecting and plotting the first peak after each valley (minimum of the inverted plot) is straightforward —
CMJ = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1061310/CMJ_ges%20-%20Kopie.txt', 'VariableNamingRule','preserve');
Static = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1061315/Static_Text_1%20-%20Kopie.txt', 'VariableNamingRule','preserve');
%% Static
% Static height
Z_Static = Static.('P Z');
Static_H = mean(Z_Static); % height of the marker in mm
%% Counter Movement Jump
Z_CMJ = CMJ.('P Z');
F_CMJ = CMJ.Frame;
[pks1,locs1] = findpeaks(Z_CMJ, "MinPeakProminence",100, "MaxPeakWidth", 100);
figure
plot(Z_CMJ)
hold on
plot(locs1, pks1, '^r')
hold off
% all jumping heights
H_Z_CMJ_ges = findpeaks(Z_CMJ, "MinPeakProminence", 100, "MaxPeakWidth", 100);
% max position marker
max_H_CMJ = max(H_Z_CMJ_ges);
% jumping height of max jump in cm
Sprung_H_CMJ = (max_H_CMJ - Static_H)/10
Sprung_H_CMJ = 46.5430
% lowest point after landing (squat)
min_CMJ = -Z_CMJ;
% [vlys,locs2] = findpeaks(min_CMJ, 'MinPeakProminence', 100, 'MaxPeakWidth',100, 'MinPeakDistance',500);
[vlys,locs2] = findpeaks(min_CMJ, 'MinPeakProminence',50);
for k = 1:numel(locs1)
nextpk(k) = min(locs2(locs2>locs1(k))); % Index Of The First Peak After Each Valley (Minimum)
end
figure
plot(min_CMJ)
hold on
plot(locs1, -pks1, 'vr')
plot(nextpk, min_CMJ(nextpk), '^r')
hold off
xlabel('Index')
ylabel('- Amplitude')
legend('Data','Valleys','First Peak After Earlier Valley', 'Location','best')
.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!