Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider the difference equation given as follows: y(n) = 0.5 y(n-1) + x(n) + x(

ID: 1831035 • Letter: C

Question

Consider the difference equation given as follows:
y(n) = 0.5 y(n-1) + x(n) + x(n-1), n > 0and y(n) = 0 for n < 0.
using MATLAB Find and plot y(n) for the following case: x(n) = r(n) – r(n – 9), where r(n) is the unit-rampsequence.
i'm not sure how to do this in matlab. Can anyone help me out?? I'dappreciate any help and would rate lifesaver. Consider the difference equation given as follows:
y(n) = 0.5 y(n-1) + x(n) + x(n-1), n > 0and y(n) = 0 for n < 0.
using MATLAB Find and plot y(n) for the following case: x(n) = r(n) – r(n – 9), where r(n) is the unit-rampsequence.
i'm not sure how to do this in matlab. Can anyone help me out?? I'dappreciate any help and would rate lifesaver.

Explanation / Answer

Here's a script. We need to be really careful here as MATLAB startscounting from 1 so y(0), x(0), r(0) are referenced by matlab asy(1), x(1), and r(1). Additionally, if we need to look at a pastelement, e.g. r(n - 9), we must initialize that array depending onn: i.e., for n< 9 and n >9, which is why I have 2 statementsto do so. Let me know if u don't understand any of the code. N = 100; % total number of points n = 0:(N-1); r = zeros(size(n)); x = zeros(size(n)); y = zeros(size(n)); % set unit ramp r = n; % reminded: matlab starts counting arrays from index 1 % x(n) = r(n) - r(n - 9) x(1:10) = r(1:10); x(11:N) = r(11:N) - r((11:N) - 9); % y(n) = 0.5 y(n-1) + x(n) + x(n-1) y(1) = x(1); % set y(0) y(2:N) = 0.5 * y((2:N)-1) + x(2:N) + x((2:N)-1); % plot data plot(n, y) xlabel('Index (n)') ylabel('y(n)')