Histogram between peeks get indecies and values
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Vatsal
el 20 de Mzo. de 2024
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!
Ver también
Categorías
Más información sobre Data Distribution Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!