How to solve difference equation in MATLAB
Ältere Kommentare anzeigen
How to solve the difference equation for
yn+1 =5/2 yn +yn-1 ,y0 =y1 =1 in terms of the roots of its characteristic equation in MATLAB ?
Akzeptierte Antwort
Weitere Antworten (2)
KSSV
am 7 Okt. 2020
n = 50 ;
y = zeros(1,n) ;
y(1:2) = 1 ;
for i = 2:n-1
y(i+1) =5/2*y(i) +y(i-1) ;
end
3 Kommentare
Betty Johnson
am 7 Okt. 2020
No error in the KSSV posted.
n = 50 ;
y = zeros(1,n) ;
y(1:2) = 1 ;
for i = 2:n-1
y(i+1) =5/2*y(i) +y(i-1) ;
end
disp(y(end-4:end))
You cannot, of course, run this out to infinity.
Walter Roberson
am 29 Aug. 2023
There are no negative coefficients, and no coefficients with absolute value less than one, and the initial values are positive. Each value is at least 5/2 times the previous one, so a lower bound would be (5/2)^(n-1) and therefore the bound to infinity is infinite
mohammed hussain
am 29 Aug. 2023
0 Stimmen
a = [1 -5/2 -1];
b = 0;
ic = [1 1];
n = 50; % 50 terms
y1 = [ic(1) filter(b, a, ones(1, n-1), ic)];
1 Kommentar
Walter Roberson
am 29 Aug. 2023
how does this differ from the accepted answer?
Kategorien
Mehr zu Structural Mechanics finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!