【问题标题】:How to find x-value of highest peak in histogram?如何在直方图中找到最高峰的 x 值?
【发布时间】:2019-05-17 14:43:58
【问题描述】:

如何将直方图中最高峰的 x 值保存到变量中?谢谢

【问题讨论】:

  • max 在第二个输出参数中返回位置。
  • 我有直方图h=histogram(file,50);,其中包含一列文件 - x 值。 y 轴上的变量是什么 - 箱中的计数?我不知道 max 的论点是什么

标签: matlab histogram matlab-figure


【解决方案1】:
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] 

【讨论】:

  • 我不知道为什么它显示的数字与直方图不同
  • 一个更简单的给出另一个结果,也与图表不同
  • 上传你的file文件,我帮你查一下
  • leteckaposta.cz/187079771 这样还是可以去讨论一下?最大峰值为 0,42 - 0,43
  • 我收到了location = [0.4022 , 0.4233]
【解决方案2】:
[Y,X] = max(h);

你试过了吗?

【讨论】:

  • 它给出一个错误:使用最大无效数据类型时出错。第一个参数必须是数字或逻辑。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-05-25
  • 2012-05-05
  • 2012-11-21
  • 1970-01-01
  • 1970-01-01
  • 2020-11-30
  • 1970-01-01
相关资源
最近更新 更多