# Corrupt the signal with zero-mean white noise with a variance of 4.

32 views (last 30 days)

Show older comments

##### 1 Comment

dpb
on 9 Sep 2022

This seems to parallel another Q? along same lines of yesterday or day before -- except it used a std deviation of 2 which would be the same thing as.

There, there seemed no discernible justification for "why"; it would have swamped the actual data shown by a factor of about 30X for no apparent reason whatsoever.

Would have to see the context for the Q? to have any idea unless it's simply a pedgogical exercise to illustrate that averaging during calculation of PSD by FFT can reduce random noise or some such---there's really no reason to add noise to a signal just to do so...

### Answers (2)

William Rose
on 9 Sep 2022

Adding random noise to a signal can be used to demonstrate that a signal that looks random in the time domain may reveal its deterministic nature in the frequency domain.

a=2; %signal amplitude

b=4; %noise variance

t=1:100; %time

x=a*cos(2*pi*t/10); %signal without noise

xn=x+sqrt(b)*randn(size(x)); %signal with noise added

Xn=fft(xn); %FFT of xn

f=0:.01:.5; %vector of frequencies, up to Nyquist

%plot the results

subplot(211); plot(t,xn,'-rx');

xlabel('Time'); title('Time Domain');

subplot(212); plot(f,abs(Xn(1:51)),'-rx');

xlabel('Frequency'); title('Frequency Domain');

The sinusoidal nature of x(t) is not obvious in the time domain plot. The frequency domain plot shows a noticable spike at 0.1 Hz, the sine wave frequency. See above.

##### 4 Comments

William Rose
on 12 Sep 2022

@KYRIAKOS PIPIGKAS, I am sorry to hear in your comment that you have been struggling with this prblem for a long time. You said "trying to compute mode shapes and frequency of this data". I assume that you intend to identify modes of vibraiotn by their appearance in the frequency domain. You said someone proposed adding random noise to the signal to aid in this approach. Adding random noise to the measured acceleraiton signals will not help you identify modes in the acceleraiton signal.

Adding random noise to the input to the system, if that is possible, can assist in identifying vibration modes, because uncorrelated noise contains power at all frequencies. Adding power at all frequencies to the input can reveal resonance frequencies in the output that might be difficult to detect otherwise. In your case, the output is the measured acceleration

Like @dpb, I am not sure what you mean by "i am finding it difficult to add the step time in the next data of acceleration". I notice that column 1 in your data file is "step time". It looks fine to me. Perhaps you are not sure how to use the time data to determine the frequencies of the FFT. The frequencies of the FFT are given by f=df*(0:N-1), where df=1/(N*dT) is the spacing of the samples in the frequency domain, N is the total number of points in the time domain, and dT is the time step size.

%Read data from file

data =table2array(readtable('METRISEIS.txt')) ;

step_time=data(:,1);

acc_x=data(:,2);

acc_y=data(:,3);

acc_z=data(:,4);

%Add noise to data

sd=2; %standard deviation of added noise

acc_xn= acc_x + 2*randn(size(step_time));

acc_yn= acc_y + 2*randn(size(step_time));

acc_zn= acc_z + 2*randn(size(step_time));

%Compute the FFTs of the data

N=length(step_time); %number of data points

dT=(step_time(end)-step_time(1))/(N-1); %time step size

df=1/(N*dT); %spacing of frequencies

f=(0:N-1)*df; %vector of frequencies

AX = fft(acc_x);

AY = fft(acc_y);

AZ = fft(acc_z);

AXn = fft(acc_xn);

AYn = fft(acc_yn);

AZn = fft(acc_zn);

%Plot results, up to the Nyquist frequency

figure;

subplot(3,2,1); plot(f(1:N/2),abs(AX(1:N/2)),'-r'); ylabel('AX'); title('No Added Noise')

subplot(3,2,3); plot(f(1:N/2),abs(AY(1:N/2)),'-g'); ylabel('AY')

subplot(3,2,5); plot(f(1:N/2),abs(AZ(1:N/2)),'-b'); ylabel('AZ'); xlabel('Frequency')

subplot(3,2,2); plot(f(1:N/2),abs(AXn(1:N/2)),'-r'); ylabel('AXn'); title('With Added Noise')

subplot(3,2,4); plot(f(1:N/2),abs(AYn(1:N/2)),'-g'); ylabel('AYn')

subplot(3,2,6); plot(f(1:N/2),abs(AZn(1:N/2)),'-b'); ylabel('AZn'); xlabel('Frequency')

The code above is based on your code but with a few changes. I compute the amplitude spectrum for the signal without noise and with noise. As you can see, adding noise obscures the details in the amplitude spectra.

##### 0 Comments

### See Also

### Categories

### Community Treasure Hunt

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

Start Hunting!