Corrupt the signal with zero-mean white noise with a variance of 4.
32 views (last 30 days)
William Rose on 9 Sep 2022
As @dpb said, it would help to know the context of the statement.
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
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
xlabel('Time'); title('Time Domain');
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.
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')) ;
%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
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.