Hello everyone ,
I'm student(from France). This is the problem : "Create a noisy gaussian function using the Matlab built-in function rand . You'll first check what rand is doing using help rand. The idea will be to create random-numbers having a mean value zero(i.e positive and negative numbers)."
I did for help rand . It's an array but I didn't understand how can i create this function . If you have clue or some advice . Thanks you very much .

 Réponse acceptée

Dimitris Kalogiros
Dimitris Kalogiros le 16 Sep 2018
Bellow is an rough attempt of mine:
clearvars; clc; close all;
%%parameters
N=2^16; % rand() outputs
M=2^7; % number of rand that we will use
%%uniformly distributed random numbers
x1=rand(1,N)-0.5;
% probability density function
h1=histogram(x1);
h1.Normalization = 'probability';
title('uniform distribution')
%%combination of M rand() functions
x2=zeros(1,N);
for k=1:M
x2=x2+rand(1,N)-0.5;
end
%probability density function
h2=histogram(x2);
h2.Normalization = 'probability';
h2.FaceColor=[0 .5 0];
title('Normal distribution');
If you run this script, you will receive :

Plus de réponses (0)

Catégories

En savoir plus sur Language Fundamentals dans Centre d'aide et File Exchange

Produits

Version

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by