Write the code using Matlab

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

Write the code using Matlab 

Given the DSP system:
y[n] = 2x[n] - 4x[n-1] - 0.5y[n-1] - y[n-2]
(a) With initial conditions y(-2) = 1, y(-1) = 0, x(-1) = -1, and the input x[n] =
(0.8)"u[n], compute the system response y[n] for 20 samples.
(b) With ZERO initial conditions, and the input x[n] = (0.8)"u[n], compute the system
response y[n] for 20 samples.
Transcribed Image Text:Given the DSP system: y[n] = 2x[n] - 4x[n-1] - 0.5y[n-1] - y[n-2] (a) With initial conditions y(-2) = 1, y(-1) = 0, x(-1) = -1, and the input x[n] = (0.8)"u[n], compute the system response y[n] for 20 samples. (b) With ZERO initial conditions, and the input x[n] = (0.8)"u[n], compute the system response y[n] for 20 samples.
Expert Solution
Step 1

Matlab code:

(a)

n = 0:1:20;

x_n = ((0.8).^n).*(n>=0);

y_n = [1 0];

 

k = 3;

for i=0:20

    if i == 0

        y_n(k) = 2*x_n(i+1) + 4 - 0.5*y_n(k-1) - y_n(k-2);

    else

        y_n(k) = 2*x_n(i+1) - 4*x_n(i) - 0.5*y_n(k-1) - y_n(k-2);

    end

    k = k+1;

end

 

stem(y_n)

title("Y[n] with initial conditions # 0")

disp(y_n)



Values :


  y[n] = [1.0000         0    5.0000   -4.9000   -4.4700    5.5990    0.4417 -6.8029    2.1733    5.0871   -5.2202   -2.8797    6.3379   -0.5470   -6.2705    3.5173    4.3799   -5.8129   -1.5580    6.5243   -1.7582   -5.6884    4.5678]



Output:


Computer Science homework question answer, step 1, image 1











 

 

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education