Histogram between peeks get indecies and values

조회 수: 2 (최근 30일)
tim pearce
tim pearce 2024년 2월 22일
댓글: tim pearce 2024년 3월 23일
Hi all,im trying to programmatically remove some data between the central peeks as shown on the image. The source data is a point cloud but the part I’m struggling is the 4 peeks are always there but their height and position may change but no matter what I need the undecided or values of the items that are always in the middle in this example 34 35 and 36. I’m not really sure where to start so any hints are greatly appreciated. Many thanks tim
  댓글 수: 2
Voss
Voss 2024년 2월 22일
"...as shown on the image"
No image is shown.
tim pearce
tim pearce 2024년 2월 22일
이동: Voss 2024년 2월 22일

Upps here we go

댓글을 달려면 로그인하십시오.

답변 (1개)

Vatsal
Vatsal 2024년 3월 20일
Hi,
From the given description, it seems like you are trying to identify and remove the data between certain peaks in a histogram.
Here is how you can do it in MATLAB:
% Assuming 'data' is your histogram data
[peaks,locs] = findpeaks(data);
% Initialize an array to hold the indices of the data to be removed
indices_to_remove = [];
% Loop through the peaks
for i = 1:length(locs)-1
% Get the start and end indices
start = locs(i);
endd = locs(i+1);
% Get the indices of the data between the peaks
indices_between_peaks = start+1:endd-1;
% Add these indices to the array of indices to be removed
indices_to_remove = [indices_to_remove, indices_between_peaks];
end
% Now you can remove the data at these indices
data(indices_to_remove) = [];
This code will find the peaks in the given data and then extract the indices of the data between each pair of peaks. It then removes this data from the original data array. Please replace 'data' with your actual data variable. The 'indices_to_remove' variable contains the indices of the data between each pair of peaks. You can add your own logic to process or remove this data as per the requirements.
Please note that the code above assumes that you want to remove all data between the peaks. If you only want to remove data between certain peaks (for example, only between the 2nd and 3rd peak), the code needs to be adjusted accordingly.
To learn more about “findpeaks” usage and syntax, you may refer to the MathWorks documentation link below: -
I hope this helps!
  댓글 수: 1
tim pearce
tim pearce 2024년 3월 23일
Thanks yes I’ve managed to put something together with find peeks Many thanks Tim

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by