Help with Graphing Difference Equations
1 view (last 30 days)
Show older comments
McKenna Mason
on 1 Oct 2022
Answered: Davide Masiello
on 1 Oct 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!
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1142105/image.jpeg)
2 Comments
Davide Masiello
on 1 Oct 2022
Hi @McKenna Mason, it is costumary on this forum that you share your attempt at coming up with a code.
Accepted Answer
Davide Masiello
on 1 Oct 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)
0 Comments
More Answers (1)
Torsten
on 1 Oct 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
csol = solve([subs(y,n,0)==2,subs(y,n,1)==5],[a,b])
y = subs(y,[a,b],[csol.a,csol.b])
simplify(subs(y,n,n)-5*subs(y,n,n-1)+6*subs(y,n,n-2))
0 Comments
See Also
Categories
Find more on Numerical Integration and Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!