c=(exp((-z​^2)/(2*sig​ma^2)))+mn​oise

1 Ansicht (letzte 30 Tage)
Ajay  Joseph
Ajay Joseph am 1 Feb. 2014
Kommentiert: Ajay Joseph am 1 Feb. 2014
How do you add mnoise which is a 251 data with normal distribution and derivation 0.02. When I added mnoise It says there is an error with + matrices

Akzeptierte Antwort

Amit
Amit am 1 Feb. 2014
mnoise = 0.02*randn(251,1);
  5 Kommentare
Amit
Amit am 1 Feb. 2014
Here, the issue is
z = linspace(-7,7,251); % This is a row vector
mnoise = 0.02*randn(1,251); % Now we made this a row vector as well
This time this will work :)
Ajay  Joseph
Ajay Joseph am 1 Feb. 2014
Damn thanks man The simplest things makes a big difference

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

John D'Errico
John D'Errico am 1 Feb. 2014
It appears you have not realized there is a difference between row and column vectors. This is a common mistake, since a vector is just a vector, right? In fact, MATLAB sees a vector as just an array with the row or column dimension equal to 1. That makes a lot of sense in a linear algebra context, which is really where MATLAB comes from.
LINSPACE (like COLON) creates row vectors, so an array of size 1 by n.
A good way to add noise to an array or vector without bothering to know the size is...
y = y + randn(size(y)).*0.02;
RANDN by default generates Gaussian deviates with mean zero and standard deviation 1. Multiplying by 0.02 scales them to have standard deviation 0.02.
  1 Kommentar
Ajay  Joseph
Ajay Joseph am 1 Feb. 2014
thanks but I guess Amit answer works aswell

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by