You are on page 1of 8

Project Description

Our project is to consist of Lab #8, Digital Sonar for Localization and
Signaling, from the Labs for Signals and Systems Using Matlab book. We were to
complete the questions from the laboratory preparation and lab experiment sections of the
lab. We were to research journals and patents for information on correlation receivers or
matched filters, and give a summary of this journal or patent. A web page presentation is
required describing our results.

Purpose/Introduction
The purpose of this laboratory is to determine if an actual signal is being sent
from a submarine to a ship. When a signal is sent, noise will corrupt the original signal.
The type of media, nearby machinery, or any other natural or man-made items can cause
this corruption. To remove the signal from this noise/signal corrupted sound a filter is
needed. Using Matlab one can design a filter that will extract the desired signal.

Objective
The objective of this lab is to simply interpret a message from a corrupted noise.
By understanding and using continuous time convolution we can accomplish this goal.
From this project the following things should be accomplished.
Time Domain
1) Identify basic building blocks in digital communication systems.
2) Design a matched filter by specifying the unit impulse response needed
to implement a correlation receiver.
3) Implement a matched filter using continuous time convolution
4) Use your matched filter implementation for estimating sonar signals in
the presence of noise and distances of objects using active
sonar.
Frequency Domain
5) Design a matched filter by specifying its frequency response.
6) Implement a computationally efficient matched filter by using the
radix-2 FFT to perform convolution.
7) Explain how a matched filter works in both the time and frequency
domains.

References
Review Topics
1) Continuous time convolution
2) Fourier transform properties
3) System frequency response

Research Topics
1) Correlation receivers
2) Matched filters
3) Computationally efficient convolution using the FFT
4) Sonar digital communication systems

Research
The journal we chose to review was Correlating matched-filter model for analysis and
optimization of neural networks. This article was found in the IEE proceedings from
June 1989. The article describes the benefits of using matched-filters in neural networks,
rather than the previously used spin-glass techniques.
The authors propose matched-filter modeling to represent the physical processes in a
neural network. Mathematical modeling using matched-filters is shown using a patternrecognition network. A pattern-recognition network is suitable for use with partial or
noisy patterns as inputs.
A pattern-recognition network works only if it is able to distinguish a signal that is
distorted or otherwise affected by noise. The network outputs received signals as a
binary bit. The network example of this journal works well because the unknown input is
multiplied by a known matrix. After being multiplied by this known matrix, the two
operations are toggled until the code settles to a stable binary state. Each bit of the input
is then set to a value of either positive or negative one.
By using an equivalent net of matched filters to replace the neural network, a more
accurate modeling technique has been developed. With the use of orthogonal stored
codes the input convergence is prevented from converging to an incorrect value. The
implementation of an equivalent matched-filter net is easily achieved by using electronic
or optical matched fibers. The increased accuracy and ease of implementation of this
modeling has allowed for networks to work more precisely, even in increased noise
situations.

Laboratory Preparation
For the lab prep section the following questions were assigned. See attached sheet for
answers and graphs.

1)

Assume that logical ones are represented by shifted positive rectangular


pulses, p(t) = u(t) u(t T/2), and the logical zeroes are represented by
shifted negative rectangular pulses, -p(t). Assume that the bit rate is T bits
per second.
a) What is the unit impulse response h(t) of a casual, matched filter for
this system?
b) Compute h(t) * p(t) and h(t) * [-p(t)].
c)

If x(t) is the waveform representing a sequence of alternating ones

and zeros starting with a 1 at t=0, sketch x(t) and y(t) = h(t) * x(t).
If you sample y(t) at T second intervals, determine at what times you
should sample, and find a criterion for determining whether a one or a
zero was sent using these samples.
2)

Assume that you sent out a sonar test signal s(t) = u(t) 2u(t-T/2) + u(t-T)
and receive the signal s(t-Td), where Td >>T.
a) Define h(t) = s(T-t) and sketch y(t) = s(t-Td) * h(t). Assume T=0.1 and
Td=20.
b)

From y(t), how can you determine the time delay Td?

3)

Look up the Matlab function conv. Show how to use this function to
generate a signal y(t) = x(t) * h(t). If x(t) is represented in Matlab by a
vector of length M and h(t) is represented by a vector of length N, then
what will be the length L for the vector, used to represent y(t), that is
returned by the conv function.

4)

Omitted

5)

Omitted

Backround
A correlation receiver acts as tool used to compare two signals and find out how
similar they are. This is accomplished by comparing the time sequences of the two
signals. A correlation coefficient is used to show how similar two signals are alike. If
they are identical the coefficient will be 1, and if they are found to be completely
different it will be 0.
There are two types of correlation, auto-correlation, and cross-correlation. Autocorrelation is when a signal is correlated by itself. This is used when it is not known what
the signal looks like without the noise, and does not return as good results as does crosscorrelation. Cross-correlation is when a signal is correlated with a different signal
(usually a known signal correlated with the known signal and noise) and yields the best
results out of the two.
Recovering sine waves works well with correlation because the energy is
concentrated at a single frequency, but a noisy square wave is not easily recovered due to
its signal bandwidth being too broad. Using a matched filter instead increases the success
of recovering the signal. This is done by time reversing the original signal and convolving
it with the signal buried in noise. Mathematically, correlation and convolution are similar.
For convolution we flip the system impulse response before performing the
multiplication and integration. The correlation receiver basically compares the two
signals.
The convolution integral is as follows:

c(t) =

x() h(t-) d

Where h(t) is the unit impulse response and x(t) is the input. If we select h(t) to be a
flipped version of the expected waveform shape for a logical 1, shifted by a bit period T
to ensure that the system is causal, then h(t) = s1(T-t) for t in [0,T] and the convolution
integral becomes:
T

c(t) =

x() s1(T-t+) d
0

Now sample c(t) at time T, the convolution integral becomes:


T

c(t)

t=T

x() s1() d

This just happens to be the same operation as the correlation receiver. By defining a
casual CT LTI system to have an impulse response equal to a flipped and shifted version
of the waveform representing a logical 1, we can match a correlation receiver. This is
known as a matched filter.

Laboratory Experiment and Analysis


You are a sonar operator on a submarine and are told to find out where a friendly
ship is with active sonar. Active sonar operates by sending a "ping" of sound and
listening for return echoes from objects. The sonar signal you send is a sinusoid of 0.25second duration. Assuming sound travels 5000 feet per second in water, an object's
distance can be calculated by measuring the return echo time. Unfortunately, a beach is
near, and there is a lot of noise in the water.
Problem 1
Determine how far away the friendly ship is by using a matched filter receiver on
the echo.
The Matlab code to determine the distance is as follows:
%Problem 1
fname='a:/P_8_1.mat';
load(fname);
n=length(y);
Rx=conv(fliplr(x),y)/(n+1);
ndt=(-(n-1):n-1)*0.01;
maximum=0;
time=0;
int=1;

while (int<length(Rx))
if (Rx(int)>=maximum)
maximum=Rx(int);
time=int;
end
int=int+1;
end
ret=time/2*0.01;
distance=(ret*5000);
fprintf('The total distance to the friendly ship is %4.1f feet.\n',distance);

The output reads: The total distance to the friendly ship is 4100.0 feet.
Problem 2
Omitted
Problem 3
Determine binary message stream sent by the friendly ship. Then decode the
message into English language.
The Matlab code to determine the message sent is as follows:
%Problem 3
fname='a:/P_8_4.mat';
load(fname);
Rx=conv(fliplr(x),y);
b=5;
d=102;
while (b>0)
c=7;
a=0;
while c>0
if (Rx(d)>=100),
chr(c)=1;
a=2^(c-1)+a;
else
chr(c)=0;
end
c=c-1;
d=d+51;
end
d=d+51;
res(b)=char(a);
b=b-1;
end
ans=fliplr(res);
fprintf('The message sent by the friendly ship was "%s"\n',ans);

The output reads: The message sent by the friendly ship was " Hi! "
Using matched filters in digital communications is essential. If noise were to be
detected many systems would not operate properly. As one could imagine this could

become extremely dangerous in some industries. If a message were sent by an alternative


format, other than binary, the decoding of a message would become extremely difficult.
For example, an analog speech signal has many different values; therefore a sample value
could be slightly off and not give an accurate reading.
Problem 4
Generate a message and encode it in a binary stream. Convert the binary stream to an
analog signal using a triangle wave 0.01-seconds long for a logical 1. Use a sampling rate
of 8 kHz. Add different levels of noise to see if you can decode the message.
The Matlab code to generate a message is as follows:
%Problem 4a
n=1;
char=10;
message='Graduation';
num_rand=double(message);
disp(sprintf('\nThe binary coded message reads: %s',message))
b=dec2bin(message);
d=[0:0.025:1 1:-0.025:0];
bits=char*7;
b=b';
for i = 1:bits,
if (str2num(b(i))==1),
q((i)*80-80+1:80*i)=d(1:80)+n*randn(1,80);
end
if (str2num(b(i))==0),
q((i)*80-80+1:80*i)=-d(1:80)+n*randn(1,80);
end
end
q=[q'];
sound(q)
wavwrite(q,8000,'ee126')

The Matlab code to decode the sent data is as follows:


%Problem 4b
y=wavread('ee126');
a=length(y);
d=[0:0.025:1 1:-0.025:0];
Rx=conv(y,fliplr(d));
max=0;
c=1;
while (c<length(Rx))
if (Rx(c)>max)
max=Rx(c);
end
c=c+1;
end
max=max/2.5;
r=(ceil((length(y)-40)/80)/7);
c=82;
while (r>0)

c2=7;
v=0;
while c2>0
if (Rx(c)>=max),
chr(c2)=1;
v=2^(c2-1)+v;
else
chr(c2)=0;
end
c2=c2-1;
c=c+80;
end
res(r)=char(v);
r=r-1;
end
ans=fliplr(res);
fprintf('The message sent was "%s"\n',ans);

As the noise began to increase, the decoded signal started to have various outputs.
The variations are as follows:
Amount of Noise
0.0
0.5
1.0
1.5
2.0

#failed decode
0
0
0
8
10

# correct decode
10
10
10
2
0

When the decoding fails it is obvious that the noise has become too strong for the
message to be extracted. Message reception can be increased by increasing the amplitude
of the signal being sent, alter the sampling rate, or even a totally different waveform.
Problem 5
Omitted
Problem 6
Omitted

Conclusion
From this lab we have learned that noise can be a large variable in the quality of a
signal. A noise can originate from anything in our surroundings. If noise is present, a
filter must be used to remove the corruption from the signal. Using Matlab we were able
to create a filter that would extract a message from a corrupted signal. As we have seen
several times in the past, Matlab is a very powerful tool and can be used to solve many
mathematical problems.