For the simulation of the narrowband interferer, you could use either a sinusoid or bandpass noise.
As an example of simulating a sinusoidal interferer outside of the transmission band, one can replace the line
n=0.25*randn(1, time/Ts );in improvesnr.m with
t = Ts : Ts : time; f0 = 1000; n = cos(2*pi*f0*t);By starting at t=Ts and ending at t=time, we ensure that signal n would have the same number of samples as signal x.
Bandpass noise can be generated by passing spectrally flat noise through a bandpass filter. The bandpass filter would have a passband width that is much smaller than the transmission bandwidth of 1000 Hz, e.g. 100 Hz or less. The bandpass filter may either be a finite impulse response filter or an infinite impulse response filter.
In this problem, there are two baseband message signals m1(t) and m2(t). Please use different baseband message signals. It simplifies the calculations if you use the same linear phase lowpass filter for the two filters in the receiver.
With the phase error, energy in transmitted message signal #1 will leak into received message signal #2, and vice-versa, which is known as cross-interference. Let's do the math. Assume that there is a phase error of theta at the receiver.
s1(t) = LPF{ m1(t) cos(2 pi fc) cos(2 pi fc + theta) - m2(t) cos(2 pi fc) sin(2 pi fc + theta) } s1(t) = LPF{ 1/2 m1(t) ( cos(theta) + cos(4 pi fc + theta ) ) - 1/2 m2(t) ( sin(-theta) + sin(4 pi fc + theta ) ) } s1(t) = 1/2 cos(theta) m1(t) + 1/2 sin(theta) m2(t)When theta = 0, i.e. when there is no phase error,
s1(t) = 1/2 m1(t)which recovers the in-phase component up to a scalar gain.
The lowpass filter in the equations above was assumed to be ideal with no delay. In practice, the input signal experiences delay through the filter by the time it reaches the output.
The delay through any LTI filter is its group delay (see slide 5-11). The group delay is equal to the negative of the slope of the phase response For a linear phase FIR filter, the group delay n0 is a constant equal to (N-1)/2 samples, where N is the number of filter coefficients. Please use an odd-length FIR filter so that the group delay through the FIR filter is an integer. The code in AM.m uses an FIR filter of order 100, which has 101 coefficients.
To compute the cross-interference in the upper channel, you'll need to align transmitted message #1 and received message #1 in time. Here are two ways:
Then, sum the squares of the samples in the difference signal to compute the amount of energy leakage. Finally, divide the energy leakage by the energy in transmitted message signal #1 to find out the fraction of energy leakage to get
2 Sum ( m [n-n ] - s [n] ) n 1 0 1 Fraction Energy Leakage = ------------------------- 2 Sum m [n-n ] n 1 0For the time alignment discussed above, you'll need to change the Matlab code for AM.m by replacing
m = 2 * filter(b, 1, x);with
m = 2 * conv(b, x);to obtain the output samples of the LPF for all input samples.
Please note the reciprocal of the fraction of energy leakage is a measure of signal-to-noise ratio at the LPF output:
Signal Power Average Power of Message #1 at LPF Output SNR = ------------ = ------------------------------------------------ Noise Power Average Power of Cross-Interference at LPF Output
You could try different phase offset values to find the phase offset that gives a different signal that has 1% of the energy of the in-phase channel when there isn't any phase offset.
Note: In the receiver in Figure 5.10, the term sin(2 pi fc t) should be -sin(2 pi fc t) to match the negation of the lower path in the transmitter.
Once you've designed your filter using the Filter Design and Analysis (FDA) tool in Matlab, you can export the filter coefficients. In the Design Filter View of the FDA tool, the upper left window has the text "Current Filter Information". Below this text, you can right click on the text "Structure" and pick either cascade of biquads or single section.
Cascade of biquads. If you leave the filter as a cascade of biquads, then for each biquad, expand the factored form of the transfer function and report the feedforward coefficients (b0, b1 and b2) and the feedback coefficients (a1 and a2). Here's how to connect the poles, zeros and gain with the coefficients using the transfer function:
-1 -1 -1 -2 (1 - z0 z )(1 - z1 z ) 1 - (z0 + z1) z + z0 z1 z H(z) = C ------------------------ = C ------------------------------ -1 -1 -1 -2 (1 - p0 z )(1 - p1 z ) 1 - (p0 + p1) z + p0 p1 zSo,
b0 = C b1 = -C (z0 + z1) b2 = C z0 z1 a1 = p0 + p1 a2 = - p0 p1
Single section. Then, under the File menu, you can click "Export". The "Export" command will by default export the filter coefficients to the Matlab workspace. The numerator coefficients will be in the Num vector, and the denominator coefficients will be in the Den vector. Then, in Matlab, you can type Num to see the numerator coefficients, and type Den to see the denominator coefficients. Moreover, you can apply the filter to a signal in Matlab using
outputSignal = filter(Num, Den, inputSignal);