How do I record the entire row of a matrix if it has a peak value in the third column?

1 回表示 (過去 30 日間)
Hi,
I have a 3 column matrix, xyK, that contains x and y coordinates and the value of curvature at each of those coordinates. I'm trying to find the peak values of curvature and the coordinates they occur at and put that information into another 3 column matrix.
findpeaks(xyK(:,3)) is returning the peak values of curvature as I need but when I tried to use [pks,locs] to find the corresponding (x,y) coordinates it's returning the distance along the curve and not the coordinates of the point the curvature occurs at. I suspect this is because the curvature is plotted against length but I have a matrix with all the corresponding values so I feel like there must be a simpler way to just lift out the rows that have a peak value in the third column?
I've attached the code, function and data that I'm working with.
Thanks in advance!

採用された回答

Alex Mcaulley
Alex Mcaulley 2020 年 2 月 25 日
Try this:
[~,locs] = findpeaks(xyK(:,3));
sol = xyK(locs,:);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDescriptive Statistics についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by