辅导案例-ECE 340:

欢迎使用51辅导,51作业君孵化低价透明的学长辅导平台,服务保持优质,平均费用压低50%以上! 51fudao.top
1
ECE 340: Discrete Time Signals & Systems, Fall 2020
Lab 1
Introduction to discrete-time signals and systems

Objective: In this Lab, you will learn how to (i) plot multiple 1-D functions in one page, (ii) read
and write audio signals in .wav format, (iii) read and write digital images in .jpg format, and (iv)
give the system response of a system, calculating the output with Matlab.

Q.1 Signal Generation and Plotting
(a) Generate the following discrete functions using MATLAB. Do not use for loops in your code.
Plot the two functions on the same page using MATLAB stem function. For 2[ ]x k , plot the
real and imaginary parts separately. Therefore, a total of three plots will be plotted on one page.
(i) 1[ ] 5.1sin(0.1 * 3 / 4) 1.1cos(0.4 * ) 10 40x k k k k  = − − + −  
(ii) /102[ ] ( 0.9) 0 100k j kx k e k= −  
(b) Are 1[ ]x k and 2[ ]x k periodic sequences? If so, what are their periods? Mark them on the plots.
(c) Calculate the total energy of 1[ ]x k and 2[ ]x k .

Q.2 Digital Audio
Digital audio (or music) have become part of our daily life. Most audio files are stored in .wav or
.mp3 format. The .wav format (used in typical Audio CD) stores audio signals as raw audio data,
and requires larger storage space, while the .mp3 format stores audio signals in compressed form
and requires less storage space. In this problem, you will learn how to read an audio signal from a
.wav file into MATLAB workspace and create an audio signal and save it as .wav file.
(a) Download the audio file baila.wav from eClass and save it in your working directory. Play the
audio signal using the system media player and listen to it using your headphone. Write down
the first few words of the song.
(b) Using the MATLAB audioread function, read the above audio file. Store the baila signal in
matrix x3.
(c) From the size of the matrix, determine the number of samples in the signal. Plot the signal over
time using MATLAB and label the axis respectively.
(d) Calculate the total energy of the audio signal x3.
(e) Generate a matrix 3 [ ]x s k by keeping the first half of x3 (the second half of 3[ ]x k is ignored). In
other words, the size of 3 [ ]x s k will be half of 3[ ]x k .
(f) Using the MATLAB audiowrite function, write 3 [ ]x s k into an output audio file. Name the
audio file as baila_half.
(g) Play the output audio signal using a media player (or use sound in MATLAB) and verify that it
is only the first half of the original sample.

2
Q.3 Digital Image
With the availability of low-cost digital cameras, digital images have become part of our daily life.
Most consumer images are stored in a format known as JPEG format, and are stored with a .jpg
extension. In this format, an image is stored in compressed form, and requires less storage space
although the subjective quality of the images is pretty good in most cases. In this problem, you will
learn how to read an image from .jpg file into the MATLAB workspace, view an image, and create
an output .jpg image.
(a) Download the image file “lena.jpg” from eClass website and save it in your working directory.
Display the image using a web browser or other app.
(b) Using the MATLAB imread function, read the image file. Store the image in matrix lena.
Using the MATLAB size function, determine the number of rows and columns of the image.
Determine the maximum pixel value.
(c) Create another matrix _lena bright using the following equation:
_ 30lena bright lena= +
(d) Save the _lena bright image in JPEG format using the MATLAB imwrite function as
follows:
>> imwrite(lena_bright,'lena_bright.jpg','jpg','Quality', 100) ;
(e) Display the _lena bright image using a web browser or other app. Comment on the subjective
quality of the _lena bright image.

Q.4 System response
The schematic of a discrete-time system is given below.
x[k]







(a) Express the relationship between input x[k] and output y[k] in the form of a difference equation.
(b) Assume that x[k] is a unit step function (i.e.,
1 0
[ ]
0 0
k
x k
k

= 

) and [ ] 0 for 0y k k=  . First
calculate, by hand, [ ] for 0 5y k k  for (i) 0.5a = and (ii) 2a = . Write a MATLAB function
sysresp to find the response y[k] of the system for 0 50k  for the two values of a. Make
sure that the computed output matches with the hand-calculated result. Plot the two outputs y[k]
in one plot. From the plots, comment on the stability of the DT system.
y[k-1]
One unit delay
a
y[k]
3
[Hints for part (b): To calculate the output, write a MATLAB function that will compute the
response y[k] of the system. You may write a function like the following. Then call this function
twice, first for 0.5a = , and then for 2a = .

function y=sysresp(x, a)
%
% computes the output in response to an arbitrary input x[n], n=0,…N-1
% assume that the system has 0 initial conditions
% input:
% x: the input signal,
% a: the system parameter
% output:
% y: the output signal

N = length(x); % length of the vector

% initialization of the output signal
% the first element in y is y[0], the second is y[1], ...
% note that in Matlab, the vector index starts from 1 and must be a pos. integer
% so the output at time n (y[n]) is the (n+1)th element in the vector y
***

% finding the remaining output
***

% plot the output
***

return

(c) Find another a that makes the above system BIBO stable. Use your sysresp function to verify
your selection with input x[k]= u[k].


欢迎咨询51作业君
51作业君

Email:51zuoyejun

@gmail.com

添加客服微信: abby12468