Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

ECE 345: Linear Systems and Signals

Summer 2022

Lab 1: signal modeling and source localization

This lab acknowledges support by Professors Sarwate and El Rouayheb.  To turn in this lab, you need to submit a  .zip le containing the following three les:

● a completed lab report in PDF format.

● a le lab1sim .m containing your lab1sim() function, and

● a le lab1est .m containing your lab1est() function.

Points will be taken off for non-PDF submissions.  Why are we being sticklers about formatting? In the real world, your work will also have to t formatting guidelines. If you bid on a government contract, for example, and don’t follow the guidelines, your bid/proposal could be rejected without review. Get in the habit of following the formatting rules!

Along those lines, do not forget to label your plots it’s part of the rubric!

1    Introduction: sound localization

  

(0, 2A)

Figure 1: An illustration of a microphone array receiving a signal (image credit: Emojipedia).

We want to nd multiple sensors to nd the direction/location of a source in a 2D plane1 . Suppose we have the setup in Figure 1. There are two speakers at locations (0, A) and (0, 2A) and a speaker at coordinates (B, L).  Our goal is to identify the location of the speaker using signals measured at the microphones. If x(t) is transmitted by the speaker then we can model the received signals as

y1 (t) = s(t - τ1 )                                                              (1)

y2 (t) = s(t - τ2 )                                                                 (2)

for the two speakers. The delays τ1  and τ2  are caused by the time it takes for the signals to reach the speakers.

Note:  We are doing this for audio signals but this works also for RF signals.  Systems like radar use antenna arrays to nd the direction of arrival (DoA) of received signals.

2    The Lab

2.1    Part 1:  simulating the received signals

In the rst part of this lab we will focus on simulating the signals that appear in this problem: the output of the microphone and the received signals at the two microphones.  We’re going to ignore the affect of path loss in this simulation, which is the volume (amplitude) that is lost when traveling over a distance.

(a)  The speed of sound is cs  = 333   m/s.  Calculate formulas for the delays τ1  and τ2  that it

takes for the sound to reach each of the two microphones. Your answer should be in terms of A, B, and L.

(b)  Suppose that the transmitted signal s(t) = 1000 cos(880πt)u(t).  What is the frequency of

this sinusoid in Hertz? Using the sig  =  @(t)  f(t) way of defining a function/signal, write a function that generates s(t). Don’t forget the u(t)!

(c) Let A = 0.5 meters and B = 100 meters.  Set L = 100 meters.  Simulate sending this s(t) over the channel using the sampling rate fs = 44.1 kHz. Use subplot to plot y1 (t) and y2 (t) for t e [min(τ1 , τ2 ) - 0.01, max(τ1 , τ2 ) + 0.01].

(d) Write a function lab1sim(A,B,L,sig) that produces as an output two functions (using sig =  @(t)  f(t)) called y1sig and y2sig that simulate y1 (t) and y2 (t).  You can verify that it works by reproducing the plot from the previous part.

2.2    Part 2: estimating the location

Next we will look at how we can use the relative delay between the two received signals to get an estimate of θ and L. This will involve a little bit of trigonmetry.

(a) It turns out that if the receiver doesn’t know s(t) then nding both τ1  and τ2  is not really

possible. Explain why this is in words.

(b) We are really only able to estimate the  relative  time  shift  between the two signals.   Use

lab1sim to generate y1 (t) and y2 (t) for t e [0, 0.5]. Then use the xcorr function to plot the cross-correlation between y1 (t) and y2 (t). If you take  [C,lags] as the output of xcorr then lags will have the integer  lag at which the cross correlation is computed.  To convert this back to time, take lags/fs to account for the sampling rate and plot C versus lags/fs to visualize the cross correlation. Zoom in to nd the peak and estimate the relative time shift.

(c) If A is relatively small and the distance between each microphone and the speaker is large 2 then the relative time shift and the angle θ are related by the (approximate) formula

 sin(θ) = τ1 - τ2 .

(3)

Use this formula to nd a formula for L in terms of A, B, cs, and τ1 - τ2 . You may wish to estimate θ first and then estimate L from that.

(d)  Compare the L you calculated from the formula with the L = 100 meters that we set above. Are they exactly the same or different? If they are different, why are they different?

2.3    Part 3: automating the estimates

Once we have a process for doing the estimation we would like to automate it. After all, who wants to find the peaks in the cross-correlation by hand?  For this part continue generating signals only for t e [0, 0.5].

(a) Now we would like to automate the process of nding the delays.  Use the max function to

find the peak in the autocorrelation and convert the corresponding lag into an estimate of the relative time shift.

(b) Write a MATLAB function lab1est(A,B,y1,y2) that outputs both the estimated angle and

L given the model parameters and the received signals.

(c) Use linspace to generate 100 evenly spaced points spaced between L = 1 meter and L = 100 meters.  Write a loop that generates signals from a speaker at location L using lab1sim() and then estimates L using lab1est().  Plot the relative error between the true L and the estimate (which we can call ):

εrel = 1 -                                                              (4)

Plot εrel  as a function of L.   Explain the general trend that you see  (there may be some oscillations).

2.4    Part 4:  impact of noise

Real systems always have noise so it’s important to investigate how robust the estimator you have is to the presence of noise in your system. We are going to use additive white Gaussian noise (AWGN), which means that the noise is made of of independent and identically distributed Gaussian N(0, 1) random variables.  We can scale the power of the noise (variance) by multiplying the noise by a scalar gain. For this part continue generating signals only for t e [0, 0.5] and L = 100.

(a) Now let’s see what happens when we add a little noise.  Generate two independent random

vectors of unit-variance Gaussian noise w1 and w2 using randn.  These correspond to w1 (t) and w2 (t), two noise signals added in to make new received signals:

z1 (t) = y1 (t) + αw1 (t) = s(t - τ1 ) + αw1 (t)                                    (5) z2 (t) = y2 (t) + αw2 (t) = s(t - τ2 ) + αw2 (t)                                    (6)

Run the same test as in (d) of Part 2 with L = 100.  Generate y1 (t) and y2 (t) using the outputs of lab1sim but add the noise to get z1 (t) and z2 (t).  Use z1 (t) and z2 (t) as inputs to lab1est instead of y1 (t) and y2 (t). Check what the difference between the estimated and true L is with α = 1 and α = 102 . Do you see any difference in the errors?

(b) Use linspace to generate 10 α values between 10 and 150.  For each value of α, generate N = 100 noisy received signals and produce 100 estimates 1 (α), 2 (α), . . . , N (α).  Then compute the average squared error

N

e =       (i(α) - L)2 .                            (7)

i=1

Plot e as a function of α .  What general trend do you notice as the noise power increases? Note: you can do this as a two nested loops over α and i = 1 to N.

(c) Explain where in your receiver program that the noise may cause errors in the estimate. Note: if you increase the noise power further you may start to get instability and the estimator will return complex numbers. Try to think of why that might happen.