MATLAB 中的直方图拟合和核密度图

Histogram fit and kernal Density plot in MATLAB

我想在一个图中绘制直方图拟合和核密度曲线意味着我在一帧中绘制 ks 密度曲线和 histfit。

谁能帮我怎么做。

我只是展示了我想做的示例代码。

非常感谢。

  x = rand([1 50])
  figure(1)
  histfit(x)
  hold on 
  [f,xi] = ksdensity(x);
  hold off
  figure
  plot(xi,f);

绘图函数调用不正确。本质上,hold on 要求 MATLAB 绘制此后的所有内容,与上一个图重叠。 hold off 禁用它并覆盖之前的数字。因此,运行 代码如下:

x = rand([1 50])
figure(1)
histfit(x)
hold on 
[f,xi] = ksdensity(x);
plot(xi,f);
hold off