# Simple Signal Smoothing via Signal Averaging using Matlab

Signal averaging is aimed to smooth signals which contain noise. The simple averaging process implemented here is using the idea of adding / summing several sequence of signals which each of them contains random noise. Next, the result of summation process is then divided by number of signal sequence added which then produced an averaged signal which has lower noise level than any of the original single signal. The implementation of the simple signal averaging is carried out using Matlab.

The complete code of signal averaging is shown below added with brief explanations

```% taking average of sinusoidal signal with randomized noise % Jonny Latuny, Feb. 21, 2012```

```close all; % close all open windows clear all; % clear all previous / existing variables in workspace```

```dt = 1/1000; % define dt value t = dt:dt:200*dt; % devine array of t sine = sin(2*pi*100*t); % generate a sinusoidal signal based on t value ```

`signal_all = []; % provide empty container to store summation result`

```for i = 1:10 % perform 10 loops in which 10 parts of signal are produced y_noisy = sine + randn(size(t)); % signal + randonm noise eval(['signal_' num2str(i) ' = y_noisy;']); % using eval to generate sequential signal segment signal_all = [signal_all; eval(['signal_' num2str(i);])]; % concatenate all 10 signal into 1 matrix end```

`signal_avr = sum(signal_all) / i; % calculating the average value`

```FT = fft(y_noisy,512); % FFT of a single signal P = FT.* conj(FT)/512; % provide FFT result for plotting```

```FT_avr = fft(signal_avr,512); % FFT of averaged signal P_avr = FT_avr.* conj(FT_avr)/512; % provide FFT result for plotting```

```subplot(2,1,1) % subplot 1 plot(P), axis([0 250 0 30]); title('Spectrum of Single Signal (10th)'); xlabel('data points'); ylabel('magnitude'); grid;```

```subplot(2,1,2) % subplot 2 plot(P_avr,'r-'), axis([0 250 0 30]); title('Spectrum of Averaged Signal'); xlabel('data points'); ylabel('magnitude'); grid;``` The above composite plot shows the results of the simple signal averaging.

The top subplot shows FFT result of a single signal which contains noise.

The bottom subplot shows FFT result of the averaged signal which calculated using 10 sequences of signal samples as implemented in Matlab codes above.