Matlab代写|Homework 1 (MATLAB Part)

这是一篇来自美国的关于matlab代写的作业案例分享

1) See 1.1 below (Plotting signals in MATLAB, delta, step, other signals)

2) See 1.2 below (convolution of rectangle functions, rectangle with ramp)

3) Write your own function y=myconv(x,h), which returns the convolution of sequence x and sequence h. Your function should determine the length of x and h, and set the length of y properly. For simplicity, assume that both x and h are zero-valued for n<0, and that they start at n=0. Apply your function to solve problems 1.2(a) and 1.2(c). Plot the signals x, h, and y.

Compare the results with those obtained using MATLAB conv() function.

1.1 Plotting discrete-time signals in MATLAB.

(1) Use stem to plot the discrete-time impulse function:

n = -10 : 10;

f = (n == 0);

stem (n,f)

(2) Use stem to plot the discrete-time step function:

f = ( n >= 0);

stem (n,f)

(3) Make stem plots of the following signals. Decide for yourself what the range of n should be.

𝑓(𝑛) = 𝑢(𝑛) − 𝑢(𝑛 − 5)

𝑔(𝑛) = 𝑟(𝑛) − 2𝑟(𝑛 − 5) + 𝑟(𝑛 − 10)

where 𝑟(𝑛) = 𝑛𝑢(𝑛).

In MATLAB, use the conv function to compute the following convolutions. Use the stem function to plot the results. Be aware about the lengths of the signals. Make sure the horizontal axes in your plots are correct.

(a) 𝑓(𝑛) ∗ 𝑓(𝑛)

(b) 𝑓(𝑛) ∗ 𝑓(𝑛) ∗ 𝑓(𝑛)

(c) 𝑓(𝑛) ∗ 𝑔(𝑛)

(d) 𝑔(𝑛) ∗ 𝛿(𝑛)

(e) 𝑔(𝑛) ∗ 𝑔(𝑛)

Comment on your observations: Do you see any relationship between 𝑓(𝑛) ∗ 𝑓(𝑛) and 𝑔(𝑛) ? Compare 𝑓(𝑛) with 𝑓(𝑛) ∗ 𝑓(𝑛) and with 𝑓(𝑛) ∗ 𝑓(𝑛) ∗ 𝑓(𝑛). What happens as you repeatedly convolve this signal with itself?

Use the commands title, xlabel, ylabel to label the axes of your plots.