代写ECE 161A Homework 2代做留学生Matlab程序
- 首页 >> C/C++编程Homework 2
Problems from text 4.23, 4.24, 4.30 (Do not turn in, just to help with the review)
Matlab problem (Need to turn in):
In this assignment, we will examine the sampling of a continuous-time sinusoidal signal xc(t) at various sampling rates. Since Matlab cannot strictly generate a continuous-time signal, you will generate a sequence {xn(nTH)} from xc(t) by sampling it at a very high rate TH such that the samples are very close to each other. A plot of xc(nTH) using the ”plot” command will then look like a continuous-time signal.
1. You can use a segment of code like the one that appears below to generate the ”continuous” signal for plotting:
t = 0 : 0.005 : 10;
f = 6.5;
xc = cos(2 ∗ π ∗ f ∗ t);
What is the frequency of the sinusoid (in Hz)? What we are doing here is actually sampling the sinusoid at a rate of 200Hz. Since this is much, much higher than the frequency of our sinusoid, the result will look like a continuous signal when plotted with the ”plot” command. You can use a statement like the one below to generate a version of the sinusoid sampled with sampling period T:
n = 0 : T : 10;
xs = cos(2 ∗ π ∗ f ∗ n);
Use a sampling frequency of 10Hz to generate xs[n]. Use the ”subplot”, ”plot” and ”stem” commands to plot xc(t) and xs[n] on the same figure. Also, plot the frequency response of xc(t) and xs[n] using freqz (or fft and fftshift ) and specify the sinusoid frequency in terms of Hz or normalized frequency. Comment on your results.
2. Repeat the above step for four other sampling rates: 5Hz, 8Hz, 13Hz and 20Hz. Comment on your results. Feel free to changes the number of samples if that helps with obtaining better plots.
3. Using the original sampling frequency of 10Hz, repeat the first step with the sinusoids fre-quency set to 3.5Hz and then again at 13.5Hz. Is there any difference between the corre-sponding discrete-time signals and the one you generated in step 1? If not, why not?
1