0% found this document useful (0 votes)
33 views

Assignment 3

The document discusses signal processing techniques including replicating a sine wave signal, calculating its autocorrelation, adding noise to generate a Doppler signal, filtering the noisy Doppler signal, and plotting the original, noisy, and filtered signals.

Uploaded by

satyaseshadri
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views

Assignment 3

The document discusses signal processing techniques including replicating a sine wave signal, calculating its autocorrelation, adding noise to generate a Doppler signal, filtering the noisy Doppler signal, and plotting the original, noisy, and filtered signals.

Uploaded by

satyaseshadri
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

AM5018: EXPERIMENTAL TECHNIQUES IN FLUID MECHANICS

ASSIGNMENT NO:3

TOPIC: SIGNAL PROCESSING

20th MARCH 2018 SUBMITTED BY


ALLEN GEORGE
AM17M013
1. Replication of signal

2. Reasons for choice of signal parameters

• The sine wave frequency is randomly chosen to 2 Hz.


• The Nyquist criteria determines the sampling frequency to be at
least two times the signal frequency. Here for better sampling I
have taken the sampling frequency to be 200 Hz. If the sampling
frequency is less than two times signal frequency, we won’t be able
to resolve the signal with frequencies less than 2 Hz.
• The number of sampling points should be high enough to get
correct waveform and maximum amplitude of the signal. If the
sampling points is less, then the waveform may not look like an
actual sine wave and even the amplitude of the signal will be much
less than the actual value. Also, the number of sampling points is
preferred to be a power of 2 because the algorithms performing
Fourier transform are very efficient in those lengths of inputs
• The Doppler signal was obtained by multiplying sine signal with
gaussian signal of mean 0 and standard deviation 1. To keep the
amplitude of the Doppler signal to be same as the sine signal the
actual gaussian distribution was divided by its maximum value to
before multiplying with the sine signal

3. Noisy Doppler signal filtering

Noise was added to the Doppler signal by using rand function.


Normally, noises will be signal of high frequency. So, they can be filtered
out by using low pass filters. Here we use the ‘butter’ function to find the
filter coefficients. In the butter function, we have to give the cut off
frequency above which all frequencies in the signal will be removed. In
the function we are entering normalized cutoff frequency which is a value
between 0 and 1. So the actual frequency of cutoff is obtained by
multiplying it with the Nyquist frequency (sampling frequency/2). Cut off
frequency is usually given slightly greater than this value (almost twice the
actual frequency). Therefore, the argument of cutoff frequency in the
2∗𝑓𝑠𝑖𝑔𝑛𝑎𝑙
‘butter’ function is given as 𝑊𝑛 = . Now using the coefficients
(𝑓𝑠𝑎𝑚𝑝𝑙𝑖𝑛𝑔 /2)
obtained from the ‘butter’ function the signal is filtered using ‘filter’
function.

The MATLAB code for plotting and performing the filtering is attached.
Please refer next page.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% MATLAB CODE TO DRAW SIGNAL, AUTO CORRELATION AND FILTERING %
% OF NOISY SIGNAL %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

clc;
close all;
clear;

% sine wave generation


N=2^13;% Number of samples
A=20; % amplitude
freq=2; % signal frequency
SF=200; % sampling frequency
n=(1-(N/2)):(N/2); %Sample index numbers
fsin=A*sin(2*pi*freq*n/SF); % sine function
t=[(1-(N/2)):(N/2)]*(1/SF); % time domain

% Question 1(a): sine wave plot


figure(1);
subplot(3,2,1);
plot(t,fsin,'r'); % sine wave plot
hold on;
plot([-5 5],[0 0],'k'); % drawing the x axis
xlim([-5 5]); % x axis limits
ylim([-1.4*A 1.4*A]); % y axis limits
xlabel('Time, t');
ylabel('X(t)');
title('Sine wave signal');

% Question 1(b) sine wave Correlation


fsin1=zeros(1,3*N);
fsin1(N+1:2*N)=fsin; % original signal modified for multiplying
fsin2=zeros(1,3*N);
fsin2(1:N)=fsin; % signal to be shifted for multiplying
autocorrsin=zeros(1,2*N); % defining autocorrelation function
% loop for finding auto correlation
for i=1:2*N
temp=fsin1.*fsin2;
autocorrsin(i)=sum(temp)/(N); % auto correlation calculation
fsin2=zeros(1,3*N);
fsin2(i+1:N+i)=fsin; % shifting of signal
end
tau=[(1-N):N]*(1/SF); % auto correlation time scale
figure(1); % auto correlation plot
subplot(3,2,2);
plot(tau,autocorrsin,'m');
hold on;
plot([-5 5],[0 0],'k'); % drawing the x axis
xlim([-5 5]); % x axis limits
ylim([-0.7*A^2 0.7*A^2]); % y axis limits

1
xlabel('\tau');
ylabel('R(\tau)');
title('Sine wave Autocorrelation');

% Question 2(a) - Noise free Doppler signal


% Doppler signal is obtained by multipliying sine wave with gaussian
wave
gaussian_dis=normpdf(t,0,1); % gaussian distribution
amp=max(gaussian_dis); % max value of gaussian distribution
gaussian_dis=gaussian_dis/amp; % making maximum value of gaussian
distribution to one
doppler_signal=fsin.*gaussian_dis; % Doppler signal
figure(1);
subplot(3,2,3);
plot(t,doppler_signal,'r'); % Doppler signal plot
hold on;
plot([-5 5],[0 0],'k'); % drawing the x axis
xlim([-5 5]); % x axis limits
ylim([-1.4*A 1.4*A]); % y axis limits
xlabel('Time, t');
ylabel('X(t)');
title('Doppler signal');

% Question 2(b) - Noise free Doppler signal autocorrelation


doppler_signal1=zeros(1,3*N);
doppler_signal1(N+1:2*N)=doppler_signal; % original signal modified
for multiplying
doppler_signal2=zeros(1,3*N);
doppler_signal2(1:N)=doppler_signal; % signal to be shifted for
multiplying
autocorrdoppler=zeros(1,2*N); % defining autocorrelation function
% loop for finding auto correlation
for i=1:2*N
temp=doppler_signal1.*doppler_signal2;
autocorrdoppler(i)=sum(temp)/(N); % auto correlation calculation
doppler_signal2=zeros(1,3*N);
doppler_signal2(i+1:N+i)=doppler_signal; % shifting of signal
end
figure(1); % auto correlation plot
subplot(3,2,4);
plot(tau,autocorrdoppler,'m');
hold on;
plot([-5 5],[0 0],'k'); % drawing the x axis
xlim([-5 5]); % x axis limits
ylim([-A A]); % y axis limits
xlabel('\tau');
ylabel('R(\tau)');
title('Doppler signal Autocorrelation');

% Question 3(a) Noisy Doppler signal


noise_A=10; % maximum magnitude of noise
offset=-noise_A/2; % offset of the signal b adding noise
noise=noise_A*rand(1,N)+offset;
noise_doppler=noise+doppler_signal; % Noisy doppler signal

2
figure(1);
subplot(3,2,5);
plot(t,noise_doppler,'r'); % Noisy Doppler signal plot
hold on;
plot([-5 5],[0 0],'k'); % drawing the x axis
xlim([-5 5]); % x axis limits
ylim([-1.4*A 1.4*A]); % y axis limits
xlabel('Time, t');
ylabel('X(t)');
title('Noisy Doppler signal');

% Question 3(b) Noisy Doppler signal autocorrelation


noise_doppler1=zeros(1,3*N);
noise_doppler1(N+1:2*N)=noise_doppler; % original signal modified for
multiplying
noise_doppler2=zeros(1,3*N);
noise_doppler2(1:N)=noise_doppler; % signal to be shifted for
multiplying
autocorr_noise_doppler=zeros(1,2*N); % defining autocorrelation
function
% loop for finding auto correlation
for i=1:2*N
temp=noise_doppler1.*noise_doppler2;
autocorr_noise_doppler(i)=sum(temp)/(N); % auto correlation
calculation
noise_doppler2=zeros(1,3*N);
noise_doppler2(i+1:N+i)=noise_doppler; % shifting of signal
end
figure(1); % auto correlation plot
subplot(3,2,6);
plot(tau,autocorr_noise_doppler,'m');
hold on;
plot([-5 5],[0 0],'k'); % drawing the x axis
xlim([-5 5]); % x axis limits
ylim([-A A]); % y axis limits
xlabel('\tau');
ylabel('R(\tau)');
title('Noisy Doppler signal Autocorrelation');

% Filtering of noisy doppler signal


[b,a]=butter(2,2*freq/(SF/2),'low'); % filter variables for removing
high frquency noises
doppler_filter=filter(b,a,noise_doppler); % filtering the signal
figure(2);
subplot(2,1,2);
plot(t,doppler_filter,'m'); % filtered signal plot
hold on;
plot([-5 5],[0 0],'k'); % drawing the x axis
xlim([-5 5]); % x axis limits
ylim([-1.4*A 1.4*A]); % y axis limits
xlabel('Time, t');
ylabel('X(t)');
title('Filtered Doppler signal');

3
% Plotting of the Noisy doppler signal
subplot(2,1,1);
plot(t,noise_doppler,'r'); % Noisy Doppler signal plot
hold on;
plot([-5 5],[0 0],'k'); % drawing the x axis
xlim([-5 5]); % x axis limits
ylim([-1.4*A 1.4*A]); % y axis limits
xlabel('Time, t');
ylabel('X(t)');
title('Noisy Doppler signal');

% End of the Matlab Code

Published with MATLAB® R2015a

You might also like