Difference between revisions of "FM Homework Assignment Questions"
(→Extra Advice) |
(→Extra Advice) |
||
Line 88: | Line 88: | ||
* '''Plotting graphs.''' It is ok to have your signal and noise traces on the same plot, provided they are easy to see after printing in order to save paper. That is plot each trace in a different colour, or in different line styles. However, for demonstrating, at the least I would like to see 3 filter plots, 2 signal/noise plots (with no more than two traces each) and 2 SNR plots. Further to this, 4-5 exploratory plots of your own to demonstrate ownership of the assignment is sufficient. | * '''Plotting graphs.''' It is ok to have your signal and noise traces on the same plot, provided they are easy to see after printing in order to save paper. That is plot each trace in a different colour, or in different line styles. However, for demonstrating, at the least I would like to see 3 filter plots, 2 signal/noise plots (with no more than two traces each) and 2 SNR plots. Further to this, 4-5 exploratory plots of your own to demonstrate ownership of the assignment is sufficient. | ||
− | * '''Using unwrap in Matlab.''' Make sure you are using unwrap correctly. Unwrap is designed to be used on an entire array at once, rather than inside a loop on a single value at a time. This is because the kth output of unwrap for the kth input value depends on the (k-1)th input etc. Note that most functions in mMtlab are designed so they have array inputs and array outputs. In many cases it makes no difference if you call a function one value at a time, or a whole array at once, e.g. the cos function. If you use unwrap within your demodulation loop on a single value at a time, the phase conversion will not work properly. So, you should have a line prior to your demodulation loop: | + | * '''Using unwrap in Matlab.''' Make sure you are using unwrap correctly. Unwrap is designed to be used on an entire array at once, rather than inside a loop on a single value at a time. This is because the kth output of unwrap for the kth input value depends on the (k-1)th input etc. Note that most functions in mMtlab are designed so they have array inputs and array outputs. In many cases it makes no difference if you call a function one value at a time, or a whole array at once, e.g. the cos function. If you use unwrap within your demodulation loop on a single value at a time, the phase conversion will not work properly. So, you should have a line prior to your demodulation loop: Y = unwrap(angle(X)); %Y will be an array of the same size as X |
− | + | ||
− | + | ||
* | * |
Revision as of 00:02, 12 April 2008
Contents
Introduction
Please feel free to use this page like a message board to ask any questions you like about the FM homework assignment.
Questions and Answers (Q&A)
Question 1
I have been trying for days, using the bilinear transform (matlab: bilinear) to convert the filters from continuous time domain to discrete time domain. For the butterworth filter, I even used the butterworth function provided by matlab (matlab: butter). Nothing worked, the frequency responses always showed a difference of about a factor of 10. I then stumbled across another discretisation method from the Control Systems Toolbox: c2d. For the first two filters, I simply used a bilinear tustin approximation ( Hn = c2d(Hn_a,ts,'tustin') ) and for the third filter, I used the bilinear tustin approximation with prewarping, as with higher frequencies, the prewarping effect is more visible ( H3=c2d(H3_a,ts,'prewarp',omega_c3) ) The approximation using a zero order hold also works, but the prewarp is more accurate. My question now: Is it mandatory that we use the bilinear() function, or is the above described method okay?
- Answer 1: <blah blah>
Question 2
Is the equation for the reference signal at the top of page 3 of the assignment? (v(t) = ...) I'm trying to integrate to get phi(t) but the integral of the message signal is always zero.
- >> syms t;
- >> sin_m_of_t = sin(2*pi*2000*t);
- >> int(sin_m_of_t, 0, 277775)
- ans = 0
so that implies that for the sinusoidal input v(t) = A + n_c(t) + j*n_s(t)? It is just a sine wave though, so I suppose it does make sense that its integral over a whole number multiples of 2*pi is zero. Also, is my upper limit on the integral correct? ( = delta * (number of samples - 1))
- Answer 2: <blah blah>
Question 3
How do we do complex numbers in Matlab?
- Answer 3: You can enter and perform operations on complex numbers in Matlab very easily, just like real numbers.bYou can use i or j to represent sqrt(-1). I suggest not using i or j as a variable in your code, as this could lead to confusion with sqrt(-1). So, as an example try entering the following to see how it works:
- >> a = 1+2i
- >> b = 2+3j
- >> c = ones(10,1);
- >> d = a*c
- >> e = exp(i*c)
Question 4
The assignment seems a little ambiguous, as the specs just indicate that the maximum absolute value of the message signal must be less than 1.
- Answer 4: You are right. In fact, the random message signal should be normalised so that its maximum absolute value is always 1. Therefore please do this in your simulation.
Question 5
I am a little confused about which bilinear transform to use... is it "[numd,dend] = bilinear(num,den,fs)" if so i am not sure what the num and den parameters should be.
- Answer 5:
Question 6
I'm having difficulty trying to set the seed of the Gaussian random number generator at the begginning of my simulation. I take it you need to declare a variable such that:
- >> seed = "some prime number";
...then go into the source block parameter for Random Number and change the inital seed parameter to "seed" and play around with seed values from your code as the assignment suggests (if you want to). But the problem I'm having is matlab won't let me change this parameter.. in fact I can't even change "mean" or "variance" not that I need but how can I gain access to change this?
- Answer 6: <blah blah>
Question 7
What exactly is required when scaling noise phasors? At the moment I have two arrays called n_c and n_s filled with values matlab spits out of randn. From page 3 we know:
- sigma = sqrt(Noise spectral density * sampling frequency)
but I don't quite get the meaning of the noise spectral density parameter on page 1 of the assignment. In particular the 10-30dB in steps of 1 dB part. Does the A^2 in that equation relate to the A parameter above it (1 V peak) or is it the amplitude of each individual noise sample?
- Answer 7: <blah blah>
Question 8
The system actually has for filters, however you are only asking for plots of the first 3. Should we include plots of H4 as well?
- Answer 8: <blah blah>
Question 9
Do we use the frequency warping equation, substitute omega_d = 2 kHZ, find omega_a, substitute omega_a for omega_m in the H1(s) equation and *then* do the bilinear transformation on it? I ask because the frequency warping I'm doing in matlab doesn't seem to have any effect on the value of omega. Is that expected?
- Answer 9: <blah blah>
Question 10
I've got "divide by 0" error message when i trying to find lamda, given equation in part7. How to solve this problem in matlab?
- Answer 10: <blah blah>
Question 11
When we plot our s_o and n_o in task 6, it asks for us to plot from 0 < 10ms. As our s_o and n_o is discreet and there will be 100k samples I'm setting my x_max to be 10 00us(10ms)/fs = 3600. Is this representation intuitive enough or would you like some manipulation so that it read 10ms.
- Answer 11: <blah blah>
Extra Advice
- Do not use symbolic variables in matlab for the assignment! You should only use symbolic variables in Matlab when you want to simplify an algebraic mathematical expression, such as factorising a polynomial, or finding the mathematical integral or derivative. This is usually not helpful for a simulation. In a simulation you should be using arrays of numbers. These numbers can either be real or complex. All integration and differentiation should be done numerically, e.g. we approximate integration by summing. Summing should be done just as if you were programming in some other language like C, i.e. use a loop. Differentiation is approximated by taking differences. Again, this is likely to be done in a loop.
- Plotting graphs. It is ok to have your signal and noise traces on the same plot, provided they are easy to see after printing in order to save paper. That is plot each trace in a different colour, or in different line styles. However, for demonstrating, at the least I would like to see 3 filter plots, 2 signal/noise plots (with no more than two traces each) and 2 SNR plots. Further to this, 4-5 exploratory plots of your own to demonstrate ownership of the assignment is sufficient.
- Using unwrap in Matlab. Make sure you are using unwrap correctly. Unwrap is designed to be used on an entire array at once, rather than inside a loop on a single value at a time. This is because the kth output of unwrap for the kth input value depends on the (k-1)th input etc. Note that most functions in mMtlab are designed so they have array inputs and array outputs. In many cases it makes no difference if you call a function one value at a time, or a whole array at once, e.g. the cos function. If you use unwrap within your demodulation loop on a single value at a time, the phase conversion will not work properly. So, you should have a line prior to your demodulation loop: Y = unwrap(angle(X)); %Y will be an array of the same size as X