The method of Matlab to draw histogram

Source: Internet
Author: User
Tags rand

Directly on the code, using hist to draw frequency histogram and frequency histogram ...

%rand fs=1000;
n=10000;
T=0:1/FS: (N-1)/fs;
X1=rand (1,length (t));

Subplot (221) plot (t,x1), Xlabel (' time (s) '), Ylabel (' A random signal with a 10,000-point sample ') title (' A random signal with a 10,000-point sample: 0-1 uniformly distributed white noise '); % RANDN usage x3=mean3+sqrt (VAR3). *RANDN (1,n)%fs=1000;
n=100000;
%T=0:1/FS: (N-1)/fs x2=randn (1,length (t));

Subplot (222) plot (t,x2), Xlabel (' time (s) '), Ylabel (' A random signal with a 10,000-point sample ') title (' A random signal with a 10,000-point sample: The white noise of the standard normal distribution); % amplitude Statistics A1=max (X1)-min (X1)% calculated amplitude%N1=HISTC (X1, (min (X1): A1/100:max (X1))) subplot (223) hist (X1, (min (X1): A1/100:max (X1))
)%%[n1,bin1]=hist (X1, (min (X1): A1/100:max (X1)))% (' 0-1 evenly distributed white noise amplitude equal to 100 of the statistical Frequency distribution ') Xlabel (' Random variable x value ') Ylabel ("Frequency statistics after 100 of random variable x amplitude") A2=max (X1)-min (X1)%N2=HISTC (X2, (min (X2): A2/100:max (X2)))%n=n2/n;x= (min (X2): a2/
100:max (X2));
%figure%plot (x,n) subplot (224) hist (X2, (min (X2): A2/100:max (X2))); Title (' Statistical frequency distribution after equal to 100 of the white noise amplitude of the standard normal distribution ') Xlabel (' Random variable x value ') ylabel (' random variable x amplitude equal to 100 of the frequency Statistic value ') [N1,bin1]=hist (X1, (min (X1): A1 
/100:max (X1));
Figure subplot (211);
Bar (bin1,n1/n); Title (' 0-1 uniformly distributed white noise amplitude equal to 100 post-statistical frequency distribution ') Xlabel (' Random variable x value ') ylabel (' random variable x amplitude equal to 100 after the statistical frequency distribution ') [N2,bin2]=hist (X2, (min (X2): A2/100:max (X2)));
Subplot (212);
Bar (bin2,n2/n); Title (' Normal normal distribution of white noise amplitude equal to 100 after statistical frequency distribution ') Xlabel (' Random variable x value ') ylabel (' random variable x amplitude equal to 100 after the statistical frequency distribution ')

The experimental results are shown in the following diagram:

2015-9-16 Less Art

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.