MATLAB Answers

solving an equation recursively

38 views (last 30 days)
ektor on 17 Jan 2018
Commented: Star Strider on 17 Jan 2018
Dear all,
I want to solve the following equation
m(t)=a(t)+k*m(t-1); t=2,...T
for the entire path m(t), with the initial condition
where ee=4;
In other words, If we solve the above equation, each m(t) will depend on past and current values of a's.
The vector a in the above equations is known, say a=randn(T,1) and k=0.4.
Any way of doing this?
Thank in advance


Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 17 Jan 2018
Yes. Use a for (link) loop.
This seems to be homework, so I’ll not post the solution I coded.


Show 3 older comments
Star Strider
Star Strider on 17 Jan 2018
@Steven Lord — Thank you!
@Staf — Note that ‘a’ is determined completely before the loop, and according to your initial post, never changes. You can access the entire vector whenever you want to. The ‘m(t)’ assignment in the for loop stores all the values of the ‘m’ vector as the loop executes. You can access all of its values after the loop completes. So ‘m’ is already a function of the past and current values of ‘a’ in each iteration.
ektor on 17 Jan 2018
Basically, each element of 'a' changes in each iteration of my code. Should I open another thread for this if the solution is different from what you proposed above. I assumed fixed 'a' to simplify the analsis.
Star Strider
Star Strider on 17 Jan 2018
How does ‘a’ change in each iteration? You never mentioned that! I was using the information you provided.
You would create and update ‘a’ as ‘a(t)’ the same way you create and update ‘m(t)’, using whatever rule you want to create and define it it. Preallocate ‘a’ as well as ‘m’.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by