In: Computer Science
In MATLAB
Write a function to create an array of N numbers with a normal distribution. Call that from a script to create 1000 numbers, with a mean of 50 and a sigma of 10.
Function:
function y=Normaldist(N,mean,sigma)
y= sigma.*randn(N,1) + mean;
end
Script to call the function:
clc;close all;clear all;
m=50;%mean
s=10;%sigma
N=1000;
disp('The array of N numbers with a normal distribution
is:');
f=Normaldist(N,m,s)'
Output
check command window for output