%program to generate Gaussian random numbers
%using the RANDN function.
%The program requires
% 1. The number of samples to be % generateed
% 2. The mean value
% 3. The standard deviation (must be > 0)
n = input('Enter the number of samples please:');
m = input('Enter the mean value please:');
s = input('Enter the standard deviation vlaue please:');
%generate all n samples. Scaled by 's' and biased by 'm'.
y=s*randn(1,n)+m*ones(1,n);
%plot the resulting data
box off
axis square
hold on
subplot(1,2,1)
plot(y);
xlabel('Sample index')
ylabel('Random number value')
%generate a histogram of the data to view the pdf}
subplot(1,2,2)
hist(y)
xlabel('Bin'),ylabel('Sample 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.