Effacer les filtres
Effacer les filtres

Using normpdf() and a for Loop to Generate Multiple Gaussian Random Variable Arrays

3 vues (au cours des 30 derniers jours)
I would like to know how I can implement a for loop to generate multiple random values for a Gaussian distribution and then plot to a histogram. My existing code is as follows:
%%Clearing and closing all other open programs withing MatLab
close all
clc
%%Creating a matrix for the signals given
equalProbSignal = [1 0 0 0 1 0 1 1 0 0 0 1 1 1 1 0 1 0 0 1];
unEqualProbSignal = [1 1 0 0 1 1 1 1 0 1 1 0 1 1 1 0 1 1 0 1];
%%Generating a Real Gaussian Noise
X = [0.1:1:0.1];
gaussianNoise = normpdf(X);
%%Adding noise to the signal
noiseySignalEqual = equalProbSignal+gaussianNoise;
noiseySignalUnEqual = unEqualProbSignal+gaussianNoise;
%%Must repeat process for Laplacian
laplaceSignal=laprnd(1,20);
noiseySignalEqual02 = equalProbSignal+laplaceSignal;
noiseySignalUnEqual02 = unEqualProbSignal+laplaceSignal;
%%Comparing the noisey signal to the transmited one for Gaussian
gaussianNoiseEq = noiseySignalEqual;
gaussianNoiseEq > 0.5; %Finding values less than or above 0.5
result=noiseySignalEqual==equalProbSignal; %Comparing the result
figure(1);
stem(result);
GaussianNoiseUnEq = noiseySignalUnEqual;
GaussianNoiseUnEq > 0.5; %Finding values less than or above 0.5
result02=noiseySignalUnEqual==unEqualProbSignal; %Comparing the result
figure(2);
stem(result02);
%%This block will contain the same as above yet with Laplacian noise.
  2 commentaires
James Hayek
James Hayek le 10 Août 2015
I have to say, I was hoping this community would of been more helpful. The lack of support doesn't really make MatLab an easy tool to learn/use. My apologies in advance for being blunt.
Arun Badigannavar
Arun Badigannavar le 10 Août 2015
James, Please go to help and look for 'FOR'loop, To create random signal,again go to help and look for 'random' you will get the usefull information

Connectez-vous pour commenter.

Réponses (1)

Bjorn Gustavsson
Bjorn Gustavsson le 10 Août 2015
helpwin randn
HTH,
Coulda been more verbose, but here it's monday morning 0800

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by