문제

again my question is related to white noise ,but with different meaning.let us compare following two code.first

function [ x ] = generate(N,m,A3)
f1 = 100;
f2 = 200;
T = 1./f1;
t = (0:(N*T/m):(N*T))'; %'
wn = rand(length(t),1).*2 - 1;
x = 20.*sin(2.*pi.*f1.*t) + 30.*cos(2.*pi.*f2.*t) + A3.*wn;
%[pks,locs] = findpeaks(x);
 plot(x)
end

using generate(3,500,10)

graph of this code is following

enter image description here

but let us change our code so that it makes zero mean with white noise

function [ x ] = generate1(N,m,A3)
f1 = 100;
f2 = 200;
T = 1./f1;
t = (0:(N*T/m):(N*T))'; %'
wn = rand(length(t),1).*2 - 1;
mn=wn-mean(wn);
x = 20.*sin(2.*pi.*f1.*t) + 30.*cos(2.*pi.*f2.*t) + A3.*mn;
%[pks,locs] = findpeaks(x);
 plot(x)
end

and graph is following enter image description here

if we compare these two picture,we could say that it is almost same,just some changes,so does matter if we make zero mean or not?for real analysis,like for finding peaks and so on.thanks very much

UPDATED: there is updated code

function [ x ] = generate1(N,m,A3)
f1 = 100;
f2 = 200;
T = 1./f1;
t = (0:(N*T/m):(N*T))'; %'
wn = randn(length(t),1); %zero mean variance 1
x = 20.*sin(2.*pi.*f1.*t) + 30.*cos(2.*pi.*f2.*t) + A3.*wn;
%[pks,locs] = findpeaks(x);
 plot(x)
end

enter image description here

and it's picture

도움이 되었습니까?

해결책

Your initial noise is uniformly distributed between -1 & +1

Your second noise is also uniformly disributed between -1 & +1, because mean is already zero, subtracting it is meaningless

in order to obtain white noise you can use randn() function:

wn = randn(length(t),1); %zero mean variance 1

You may not observe any much difference again if your noise coefficient A3 has a much lower value compared to 20 & 30 which are the coefficients of your signal.

In order to find peaks, adding noise may not serve any purpose because noise tends to decrease the information content of signals

다른 팁

What is the value of mean(wm)? If it is close to zero, then no, it does not matter.

Technically, white noise has zero mean by definition.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top