Help with Graphing Difference Equations

1 Ansicht (letzte 30 Tage)
McKenna Mason
McKenna Mason am 1 Okt. 2022
Beantwortet: Davide Masiello am 1 Okt. 2022
I'm trying to graph these and a hint was given to use the power and semilogy functions. General advice or help with a) would be appreciated!
  2 Kommentare
Davide Masiello
Davide Masiello am 1 Okt. 2022
Hi @McKenna Mason, it is costumary on this forum that you share your attempt at coming up with a code.
McKenna Mason
McKenna Mason am 1 Okt. 2022
@Davide Masiello Ah okay my bad! I didn't initially share it because even after some google searches I wasn't sure where to start
I haven't included initials or coefficients yet either

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Davide Masiello
Davide Masiello am 1 Okt. 2022
n = 10;
x = zeros(1,10);
x(1) = 2;
x(2) = 5;
for idx = 3:n
x(idx) = 5*x(idx-1)-6*x(idx-2);
end
semilogy(1:n,x)

Weitere Antworten (1)

Torsten
Torsten am 1 Okt. 2022
syms x n a b
f = x^2-5*x+6;
xsol = solve(f==0);
y = a*xsol(1)^n + b*xsol(2)^n
y = 
csol = solve([subs(y,n,0)==2,subs(y,n,1)==5],[a,b])
csol = struct with fields:
a: 1 b: 1
y = subs(y,[a,b],[csol.a,csol.b])
y = 
simplify(subs(y,n,n)-5*subs(y,n,n-1)+6*subs(y,n,n-2))
ans = 
0

Kategorien

Mehr zu Numerical Integration and Differential Equations finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by