matlab畫頻率分布直方圖


Generate 10,000 random numbers and create a histogram. The histogramfunction automatically chooses 
an appropriate number of bins to cover the range of values in x and show the shape of the
underlying distribution.
x = randn(10000,1);
h = histogram(x)

randn(100001)產生10 000個均值0,標准差1的正態分布隨機數。


 


 

另一個例子:

clc
clear
close all

imgColor = imread('one_section_bianjihou.jpg');
imgGray = rgb2gray(imgColor);

%% imhist
figure('name', 'imhist'),
imhist(imgGray);

%% histogram
figure('name', 'histogram auto'),
% histogram函數自動計算NumBins值
hist2 = histogram(imgGray);
% Find the bin counts
binCounts = hist2.Values;
% Get bin number
binNum = hist2.NumBins;

%% histogram 指定NumBins值
% Specify number of histogram bins
figure('name', 'histogram256'),
hist256 = histogram(imgGray, 256); % 等同於 imhist(imgGray)

 

 



 

https://www.cnblogs.com/gxcdream/p/7710729.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM