Subject: Project Question Q: Hi, I have a question about the project. I'm working on the Magnitudee_Response_Plot. I'm writing an if statement in matlab to detect if h is real. I found a function called "imag" which will return the imaginary part of the input. I am checking to see is imag(h) is 0, if so then h is real. Is this approach correct? A: Yes, that's the way to go except if h is a vector, imag will return a vector and this may hose the if statement. Instead do something like if ~any(abs(imag(h)) > 10*eps) h = real(h); % h is real (do what you want here) else % h is complex (do what you want here) end; This first compares the magnitude of the imaginary components to 10*eps where eps is the machine epsilon (precision of the computer). If there are none exceding 10*eps, we simply take the real part of h. Remember, due to numerical roundoff, very small imaginary parts are possible even though the number may be real. If you don't have the any command, just loop through each value of h testing for abs(imag(h(k))) > 10*eps. ------------------------------------------------------------------------------- EE495: If you wish to do Problem #4, it will be considered extra credit and worth 3 1/3 extra points on the 10 point scale. Be sure you go over the gradtuate portion of the homework assignment regarding filter banks so you know what's going on. It's really easy so by all means try it! ------------------------------------------------------------------------------- On the convolution tool, the output should read: Output: y = [y(0), y(1), y(2), ... , y(N+M-2)] Remember you can test this tool by using some of the examples and homework problems that did convolution. ----------------------------------------------------------------------------- Subject: Project Question Q: I have a question about the fs (optional) part on Magnitude and Phase response plots. Does fs(optional) mean that we should create a function that uses h without fs in the first if statement or does this mean that fs=0 when it is typed in by the user? A: fs(optional) means that first you should check to see if fs has been entered by the user. If it has use this as the sampling frequency. If the user does not specify an fs, default to fs = 2pi. This is a common user interface technique found in a lot of UNIX commands. ----------------------------------------------------------------------------- Subject: Optional Arguments Hint For the fs(optional), MATLAB has a function, nargin which tells you how many arguments have been passed to the function. Use this. If your version of MATLAB doesn't have this let me know. If you're not using MATLAB you'll probably want to write a shell script to call your mag_resp tool and then call your plot program with appropriate params. Other possibilities exist. ----------------------------------------------------------------------------- Subject: Project Question Q: Few questions for you. You say that for the MAGNITUDE_RESPONSE_PLOT, step #4, Y-axis should be labeled as Magnitude (dB), x-axis should be labeled as w (radians). However, in the next line you say that the x-axis should be w (radians) only for fs=2*PI. This brings up my questions. 1) If we have an w not eqaul to 2*PI, should we convert to Frequency (Hz) like it says in step #5? 2) Just checking here. If we must convert, it is 1/fs, right? 3) In the mail you sent before (listed above), you say that we should assume 2*PI for fs if it's not entered. But, you say that 0<=w<=2*PI is for complex values. Does this mean that if it's not given that H(e^jw) will be complex? Or, is it okay to assume fs=PI? A: The x-axis should always be scaled and labeled according to the value of fs. I should have said that the x-axis should be w (radians) only for fs=2*PI, normalized frequency (f/fs) for fs = 1, and frequency (Hz) for anyother fs. As you should know, you scale w (radians) by fs/(2Pi) so that w = 0 gets mapped to f = 0, and w = 2Pi gets mapped to fs. Everything in between is linearly scaled. You need to check h and determine whether it is real-valued or not. If it is plot only 0 <= w <= Pi, 0 <= f/fs <= 0.5, or 0 <= f <= fs/2 depending on the value of fs. Otherwise you need to plot 0 <= w <= 2Pi, 0 <= f/fs <= 1, or 0 <= f <= fs. H(ejw) will almost always be complex. -----------------------------------------------------------------------------