HW3 Matlab
HW3 Matlab
Q1(P2.1) Generate the following sequences using the basic MATLAB signal
functions and the basic MATLAB signal operations discussed in chapter 2 of the
reference book. Plot the signal using the stem function.
(1) 𝑥1 (𝑛) = 3𝛿(𝑛 + 2) + 2𝛿(𝑛) − 𝛿(𝑛 − 3) + 5𝛿(𝑛 − 7), −5 ≤ 𝑛 ≤ 15.
Hint : you can generate each sequence manually or implement and invoke functions such
as impseq() from the reference book to get the each sequence and results.
Q2(P2.4) Let x(n) = {2 ,4, -3, 1 (↑) , -5, 4, 7}. Generate and plot the samples (use
the stem function) of x3(n).
x3(n) = x(n + 3) × x(n - 2) + x(1 - n) × x(n + 1)
Hint: you may want to implement and invoke sigfold(), sigshift(), sigmult() and
sigadd().
1
Q3(P2.15) Calculate the convolution y(n) = x(n) ∗ h(n) of the following two
sequences,
x(n) = {2, -4, 5, 3 , -1, -2, 6}, h(n) = {1, -1 , 1, -1, 1}
↑ ↑
(a) use the Matlab function conv(.),
(b) use the conv_m(.) function from the reference book,
(c) apply subplot to show your results from (a) and (b), verify the sequences
has the same shape,
(d) what is the difference between these two functions?
Q4. Bonus
Step1: Create a 25-point sequence (array with 1 row) n, from 0 to 24,
Step2: Create a 25-point sequence : x(n) = cos [2πn×(0.2)]
Step3: Create a sequence h(n):
0.5, 𝑓𝑜𝑟 𝑛 = 1
ℎ(𝑛) = {0.5, 𝑓𝑜𝑟 𝑛 = 2,
0, 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒
Step4: Calculate the convolution between h(n) and x(n), plot your result with the
stem function.
Step5: Discussion: by checking either the math or your plot results between in
input and output, can you explain what the function for sequence h(n)?