Help with Graphing Difference Equations
조회 수: 12 (최근 30일)
이전 댓글 표시
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
Davide Masiello
2022년 10월 1일
Hi @McKenna Mason, it is costumary on this forum that you share your attempt at coming up with a code.
채택된 답변
Davide Masiello
2022년 10월 1일
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
추가 답변 (1개)
Torsten
2022년 10월 1일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Mathematics and Optimization에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



