You are on page 1of 11

1

Matlab Based Radar System, Utilizing Correlation


Saifullah Amin1, 2
1
Center for Excellence in Science and Applied Technology CESAT, Islamabad, Pakistan
2
Department of Electrical Engineering, Institute of Space Technology, Islamabad, Pakistan

ABSTRACT Fs=11025; % Sampling frequency is same as


used for reading the data
n=0:(1/Fs):(2-(1/Fs));% Specifying the
A Radar system is implemented via Matlab. Distance sampling axis, As '0' is also included in
between the source and the target object is sampling so...
determined through delay in propagation of sound ... The size of n
for transmitted signal and received signal. Different was increasing by one unit, so that one
sounds are checked to test which one gives better unit i.e ...
results for a Radar system. ... the step
is minused.
I. Matlab Code subplot(312) % Subplotting on 2nd position
of a 3x1 matrix graph window
%Radar System stem(n,(DelayedSignal)); % Discrete time
%% plotting of Recieved signal, with noise
clc and delay
clear all title('Recieved (delay+Noise) Signal')
close all xlabel('Samples')
%% ylabel('Signal Strength')
%This section of code reads a portion of a %%
sound file subplot(311)% Subplotting on 1st position
Fs=11025;% Setting the sampling Frequency of a 3x1 matrix graph window
filename = stem(n,AR)% Dicrete time plotting of
'C:\Users\Saif\Documents\MATLAB\DSP\Radar\ Transmitted sound
1.mp3';% Path of the sound file that is to title('Transmitted Signal')
be transmitted xlabel('Samples')
samples = [1,2*Fs];% Specifying the ylabel('Signal Strength')
reading time (2 Seconds) %%
clear y Fs CR=xcorr(DelayedSignal,AR);% Cross
[AR1,Fs] = audioread(filename,samples);% correlation of Recieved signal...
Reading the sound file ...with the
AR=AR1*[1 1]; Transmitted signal
sound(AR,Fs);% Playing the sound file via subplot(313)% Subplotting on 3rd position
Matlab of a 3x1 matrix graph window
%% stem(CR) % Discrete time plotting of the
% This section of Code records a sound for Cross correlated signal
specified duration of time title('Correlated Signal')
recObj = audiorecorder(11025,8,1); xlabel('Samples')
% Properties of audiorecorder object are ylabel('Signal Strength')
SampleRate: 11025; TimerPeriod: 0.0500 %%
disp('Recording Started') % Message is Sr=Fs; % Sampling frequency is set the
displayed on Command window same once again
recordblocking(recObj, 2);% Recording the [pks,locs]=findpeaks(CR,'minpeakdistance',
sound for 2 Seconds 30,'NPEAKS',2);
disp('Recording Ended');% Message is %Minpeakdistance tells that start
displayed on Command Window searching for next max peak after
DelayedSignal = getaudiodata(recObj);% ...specified time
Store the data of recorded signal in a %Npeaks tells that how many peaks have to
variable be detected
%pks = tells the peaks values
%locs = Shows position at which peak occur
2

Mn=min(locs);% Highest value of locs s=v*D;%Distance = speed * Time


vector (Larger peak) display('Distance in meters from source to
Mx=max(locs);% Lowest value of locs vector reciever is:')
(Lower peak) disp(s);% Displays The Physical Distance
delay=Mx-Mn;%Sample delay in samples value
D=(delay/Sr);%Real time delay in seconds
v=332;%Speed of sound in meter/second

(Internal Mic, External Speakers)

Figure.1: For Beeps

(Output of Radar, when the sound used are beeps for 2 seconds)
(Practically Measured Distance = 130 cm i.e. 1.3 Meters)

(Output of Radar, when the sound used are Two Decreasing Beeps for 2 seconds)
(Practically Measured Distance = 130 cm i.e. 1.3 Meters)
3

Figure.2: For Two Decreasing Beeps

Figure.3: For Two Increasing Beeps

(Output of Radar, when the sound used are Two Decreasing Beeps for 2 seconds)
(Practically Measured Distance = 130 cm i.e. 1.3 Meters)
4

Changing the Time of Transmission from 2 Seconds to 5 Seconds


Outputs (For 5 Seconds)

Figure.4: For Beeps

(Output of Radar, when the sound used are beeps)


(Practically Measured Distance = 130 cm i.e. 1.3 Meters)

(Output of Radar, when the sound used are Three Increasing Beeps for 5 Seconds)
(Practically Measured Distance = 130 cm i.e. 1.3 Meters)
5

Figure.5: For Three Increasing Beeps

Figure.6: For Two Decreasing Beeps


(Output of Radar, when the sound used are Two Decreasing Beeps for 1 seconds)
(Practically Measured Distance = 130 cm i.e. 1.3 Meters)
6

(External Mic, External Speakers)

Figure.7: For Crackling Beeps

(Output of Radar, when the sound used are crackling beeps for 2 seconds)
(Practically Measured Distance = 130 cm i.e. 1.3 Meters)

(Output of Radar, when the sound used are Decreasing Chopping Beeps for 2 seconds)
(Practically Measured Distance = 130 cm i.e. 1.3 Meters)
7

Figure.8: For Two Decreasing Beeps

Figure.9: For Maintained Beep

(Output of Radar, when the sound used are Maintained Beeps for 2 seconds)
(Practically Measured Distance = 130 cm i.e. 1.3 Meters)
8

Changing the Time of Transmission from 2 Seconds to 3 Seconds


Outputs (For 3 Seconds)

Figure.10: For Crackling Beeps

(Output of Radar, when the sound used are beeps)


(Practically Measured Distance = 130 cm i.e. 1.3 Meters)

(Output of Radar, when the sound used are Chopping Beeps for 5 Seconds)
(Practically Measured Distance = 130 cm i.e. 1.3 Meters)
9

Figure.11: For Three Increasing Beeps

Figure.12: For Two Decreasing Beeps

(Output of Radar, when the sound used are Maintained Beeps for 5 seconds)
10

(Practically Measured Distance = 130 cm i.e. 1.3 Meters)

Workspace

Figure.13: Distance between laptop + External Speakers and Target=Cupboard is 1.3 Meters

Figure.14: Equipment = Laptop + External Speakers


Time domain explanations: Starting time of the recorded signal is approximately same in every figure as for
transmitted signal, because, as recording starts, transmitted signal also gets recorded along with received signal.
11

Amplitude explanations: Amplitude of the received signal is less than transmitted signal because of the attenuation.

Received signal shape explanations: Transmitted and received signal are not exactly same shape because of the
addition of noise.
Transmitted signals have gaps (some samples have no values) but received signal don’t have gaps (all the samples
have values, generally). It is because of 2 reasons
 Addition of noise
 Addition of transmitted signal in received signal.

Code explanations: Sampling frequency is set 11025 Hz because it is the sampling frequency of my laptop (Haier,
i3) minpeakdistance is set as ‘x’. It means that the highest peak of signal is searched out and after x samples, next
peak or next highest peak are searched out around the highest peak.

Conclusions: T0w sounds are used to test that which sound gives good results for the Radar system. Sounds that are
sharp (High Amplitude) and short duration are better than sounds that are for long duration. Moreover, results can be
improved through filtering the noise but here noise is also considered for natural/unaltered received sound results.

Reason: Sounds that are sharp (High Amplitude) and short duration are better than sounds that are for long duration
because noise will not distort a high amplitude signal as much as it distorts the low amplitude. When the sound is
long duration then noise factor can increase and moreover there are chances that the signal gets distorted. Short
distance gives better results than long distances when experiments are done in congested areas, because there can be
many reflections and noise and the chances for the signal to get distorted are higher. Large distances give better
results than short distances when the experiment is conducted in hilly/ mountainous areas. Less reflection and the
time delay is so much that a person can easily differentiate between transmitted signal and the received signal.