Hello, I\'ve posted this question for matlab code but matlab doesn\'t accept neg
ID: 2268470 • Letter: H
Question
Hello, I've posted this question for matlab code but matlab doesn't accept negative values or zeros,here is the code like here (m(-1) = 0;)
m(-1) = 0;
m(2) =0;
for k = 0:3
if (k==0)
e(k) = 1;
m(k) = e(k)+m(k-1)+m(k-2);
else
e(k) = 0;
m(k) = e(k)+m(k-1)+m(k-2);
end
StudefHl ID Recal, an a linear and time invariant DT systems can be modeled by a difference equation with constant coefficients of the form y(k)-yo ba(k-i)-y.lajy(k-j) for k=0, 1,2,.." Part I (in-class 1. Identify the orders (m ad n) of the following difference equation: y(k #3)-6y( k ) + y(k-1) = x(k) orders 2. Write a different equation with order of m=2 and n=2 3. A digital filter is described by the following difference equation m(k)-m( k-1) + m(k-2)-e(k ): k 0, 1,2,3, a. solve for the first four values of m(k) using the sequential technique if the with m(-1 ) = m(-2) = 0 mco) -o-o = 1 Part II (take home assignment) m2)-m(-1), Write a MTALB program that calculate m (k) in part (3) Please submit the take-home part no later in class on Wed Feb 7 2018Explanation / Answer
The code is a general purpose code which can be extended to any order with change in equation only.
Code:
clc
clear all
close all
%since matlab cannot take less than & equal to 0 indices. We consider
%initial condition start from order of the system.
ord=input('Enter Order of the system: ');
for j=1:ord;
m(j)=0;
end
e(1)=1;
for i=ord+1:ord+4;
if(i==ord+1)
e(i-ord)=1;
else
e(i-ord+1)=0;
end
m(i)=e(i-ord)+m(i-1)-m(i-2);
end
fprintf('The first four values of m(k) are: ' )
disp(m(ord+1:end))
Output:
Enter Order of the system: 2
The first four values of m(k) are:
1 1 0 -1
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.