% File name: uniform_dist.m
% Generate random numbers having the uniform
% distribution in the range between 0 and 1.
% Two plots are produced. One on left is the
% plot of numbers that result.
% One on right is a histogram.
n=1000;
%number of samples producedy=rand(1,n);
%generate all n samplesubplot(1,2,1)
% Plot the values of all the numbers generated
plot(y,
'k');%plot the resulting databox off
axis square
xlabel(
'Sample index')ylabel(
'Random number value')% Polt a histogram of the data to view the pdf
x = 0:0.1:1;
subplot(1,2,2)
hist(y)
box off
axis square
xlabel(
'Bins')ylabel(
'Bin count')
Go back to book Homepage | Go back to book's matlab Homepage | Go back to book's Chapter 1 Homepage |
Copyright © 2001 Northstar Digital Design, Inc.