Как найти значение х самого высокого пика в гистограмме? - PullRequest
0 голосов
/ 17 мая 2019

Как сохранить значение x самого высокого пика в гистограмме в переменную? Спасибо enter image description here

Ответы [ 2 ]

2 голосов
/ 17 мая 2019
fileID = fopen('q65.txt','r');
formatSpec = '%f';
file = fscanf(fileID,formatSpec);

h = histogram(file,50);
%Find index of maximum
[~, index]= max(h.Values);

delta = h.BinLimits(2)-h.BinLimits(1);
% find the range for a single bin
slot = delta./h.NumBins;

%location = minimum y + (index of maxmium)*slot 
lb = h.BinLimits(1) + (index-1)*slot;
ub = h.BinLimits(1) + (index)*slot;

location = [lb, ub]

Расположение: диапазон , а не фиксированное число

Простое

fileID = fopen('q65.txt','r');
formatSpec = '%f';
file = fscanf(fileID,formatSpec);
h = histogram(file,50);
%Find index of maximum
[~, index]= max(h.Values);
lb = h.BinEdges(index);
ub = h.BinEdges(index+1);
location = [lb, ub] 
0 голосов
/ 17 мая 2019
[Y,X] = max(h);

Вы пробовали это?

...