Histogram between peeks get indecies and values
조회 수: 2 (최근 30일)
이전 댓글 표시
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
답변 (1개)
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!
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Distribution Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!