Info
This question is closed. Reopen it to edit or answer.
How do I write a code for a linear system in the form a(n+1) = c*a(n) + b
1 view (last 30 days)
Show older comments
How do I write a matlab code to solve a linear dynamical system of equations in the general form of a(n+1) = c*a(n) + b with an initial value a_0 and the steps range from 1 to N
3 Comments
Walter Roberson
on 29 Jan 2020
Edited: Walter Roberson
on 29 Jan 2020
a_0*c^n-b/(c-1)+b/(c-1)*c^n
is the general solution
Answers (1)
KSSV
on 29 Jan 2020
N = 100 ;
a0 = rand ; % initial a
b = rand ; c = rand ;
a = zeros(N,1) ;
a(1) = a0 ;
for n = 2:N
a(n) = c*a(n-1)+b ;
end
2 Comments
Carlyn Thomsen
on 29 Jan 2020
If I wanted to plot the results for the values of a(n), with an a(n) vs n graph, what would be the code for that?
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!