create a normal distrubution in matlab in matlab

To create a normally distributed data in MATLAB, you can use the normrnd() function provided by the Statistics and Machine Learning Toolbox.

The normrnd() function generates random numbers from the normal (Gaussian) distribution with mean mu and standard deviation sigma. Here's an example code snippet to create a normally distributed data:

main.m
% Example code snippet
mu = 0;              % mean value
sigma = 1;           % standard deviation
data = normrnd(mu, sigma, [100, 1]);   % generates 100 random numbers from the normal distribution
198 chars
5 lines

In the above code, we first set the mean value mu and standard deviation sigma. Next, we use normrnd() function to generate 100 random numbers using these parameters.

You can change the mean value and standard deviation as per your requirement.

related categories

gistlibby LogSnag