LAB 2 F

LAB 2 F

LAB 5 F. A. Q.


Updated on 11-Feb-2000



0. Some of these questions don’t seem to make sense with respect to this semester’s lab.


ANSWER: Correct. The FAQs are based on the labs from Fall-99. Refer to that lab description when certain section numbers are cited.



 


(5) I don’t have the barb.mat file for lab 5. I entered the command which barb.mat, but it was unsuccessful. How can I obtain this file?

ANSWER: Get it from Web CT, there you will find a “Lab” link called barbara.zip, which contains the file barbara.mat.



 


(5) What images should be printed and attached to the lab report? The instructions do not specifically state which pictures should be observed vs. which should be printed.

ANSWER: My rule of thumb would be: include those images that you are going to talk about in the text of the report. Images included without discussion aren’t worth much in general. You are trying to illustrate how well reconstruction works, so show the original and the various reconstructions to support your discussion.

 


(5.3.1) When I try to use the plotspec function using plotspec(xx,[],fsamp),


I get the following error:

Warning: Empty matrix multiplication with unequal inner dimensions.


> In c:matlabbinspectgr.m at line 59


In c:matlabbinplotspec.m at line 35 ???


Error using ==> / Matrix dimensions must agree.


Error in ==> c:matlabbinspectgr.m On line 60 ==> T = (L/2 + shift*(0:num_segs-1) ) / fs;


Error in ==> c:matlabbinplotspec.m On line 35 ==> [B,F,T] = spectgr(xx,Lfft,fsamp,Lwindow,Noverlap);

ANSWER: plotspec uses different parameters than specgram.m that we use in the CoC lab. Here is the help


PLOTSPEC plot a Spectrogram as an image (take care of all the default settings)


usage: him = plotspec(xx,fsamp,Lwindow)


him = handle to the image object


xx = input signal

fsamp = sampling rate


Lwindows = window length

USE this function ONLY if you do NOT have specgram



 


(5.3.2(a)) When I use 0 Hz as the initial frequency for my chirp signal I get a constant frequency instead of the expected chirp. Any suggestions as to why this might be?

ANSWER: Sounds as though you might be missing the t-squared term in your formula.

 


(5.3.4(b)) How do I assign an array to an element of another array?

ANSWER: As MATLAB says, the two sides of the assignment have to be the same size. So, you can create a row and assign it to a row of an existing matrix. Run the following example:

xx = zeros(3,4) %– makes a 3 by 4 matrix


xx(2,:) = [ 1, 3, 6, 2 ] %– changes the 2nd row of xx



 


(5.3.2(e)) We are asked to make a sketch (by hand) of the "actual instantaneous frequency versus time”, but isn’t this the same as the spectrogram or plotspec we make in part (c)?

ANSWER: It should be if you do it correctly. The sketch should be done from a mathematical formula, so this is an attempt to have you cross-check: math vs. MATLAB.

 


(5.3.3(b)) I analyzed the 2 Barabara.mat images (one 448 x 393 and the other sampled down by a factor of 2). In order to find the frequencies, I looked for number of pixels within a given interval. In the downsampled image, I again looked for the number of pixels in the same interval, and find a difference. The downsampled image appears to have half the frequency. How do we relate this to the sampling theorem? For the downsampled image, the sampling frequency also halves along with the maximum frequency, apparently effecting NO change, and yet there seems to be a linear relationship between the two cases, since it is obvious from the images that aliasing has taken place.

ANSWER: This requires what I’ll call “long shot reasoning.” High frequencies will alias, low frequencies won’t. If you try to write some equations, it MIGHT go like this:


x[n] = cos(0.95*pi*(0:100)) versus n is a high-frequency signal. Plot it to see why. What is the period? If you take every other sample, and you now take every other sample (i.e., down sample) y[n] = cos(0.95*pi*(0:2:100)) and plot y[n] vs. n, I’ll be it won’t look high frequency anymore. Try it and see, and figure out the period.

 


(5.3.4(e)) I need help to linearly interpolate a two-dimensional matrix. The example we are given only shows how to interpolate a 1-D matrix. I am having trouble with the second call to the interp1 function, and am not sure how to make it process only the rows or only the vectors.



ANSWER: Consider a 2D matrix as a combination of two 1D vectors. So, here are the steps:


    1. Apply the interpolation to the rows

    2. Transpose the matrix

    3. Apply the interpolation to the rows (these rows are the columns of the original matrix)

    4. Transpose back again

 


(5.3.4(e)) When we do the linear interpolation, do we conduct it on the down-sampled image or the image that we just reconstructed?

ANSWER: Perform the interpolation on the down-sampled image. You want to show that it is a better reconstruction.

(5.3.4(e)) I’m having trouble determining what to use for the values of n1 and xi for this part of the lab.

ANSWER:


x1 = signal values before interpolation


n1 = indices where you have the x1 values.


xi = new locations for values **between** the n1 indices.


yi = interp1( n1, x1, xi ) will be the interpolated values.

 


(5.3.4(e)) I understand how to interpolate the figure for the columns, but I’m having difficulty expanding the rows. I used transpose, but I’m not sure if that is correct because it flips my image. Any suggestions?

ANSWER: Transpose, then interpolate, then transpose back.