recurrent solution of difference equation
Afficher commentaires plus anciens
Hello,
We were tasked with solving the difference equation with recurrent solution
difference equation u(k) - 0.8u(k-1) - 0.16u(k-2) = e(k)
with initial conditions: e(k) = 0.5 sin2k for k ≥ 0
u(-1) = u(-2) = 0
I solve this on paper, beacuse we must first solve on paper then verify in MATLAB and I have problem to write a code for that. I tried to write some code, but my results are not the same from Matlab and on paper.
My code:
clc;
clear all;
close all;
n=15;
u=zeros(15,1);
u(1:2)=[0.017,0.0484]
for k=3:n
u(k)=0.5*sin(k*2)+0.8*u(k-1)+0.16*u(k-2)
end
So, can anyone help me with code?
Thank You in advance
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Mathematics dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!