Problem uses time as index [var(+1), var2(-1)]. How do I use the index in calculation of a function y=C*exp[k*t]?
3 次查看(过去 30 天)
显示 更早的评论
I am running a dynamic general equlibrium economic model that uses multiple equations of motion where var(+1) = function of var.
I want to add an independently calculated parameter G where G(+1) = function of G. However, I need to include two paramenters, the value at T=0 and the growth parameter. I searched help and found the function y=C*exp[k*t] that seems to do the trick. C is the initial value, and k can be adjusted to make the resulting curve what is desired. My issue is how to use the time index inside the equation.
For example, if C = 1 and I adjust k so I have 3% growth I want the following set of values
G(0) = 1.0, G(1)=1.03, G(2)=1.0609 ...
I need to be able to use these values in other equations where foo(+1) = function (bar, blah, G, other stuff)
I have everything else. What I am missing is the equation(s) that calculate the G vector and assign values that can be used with the relative time index.
Thanks for your assistance.
0 个评论
回答(1 个)
Arun
2023-10-13
Hey Michael,
I understand that you want to use the time index inside the equation to calculate the value of vector G.
Element-wise multiplication (.*) can be used to calculate the value of vector G.
You can use the below provided sample code snippet:
G=c*exp(k.*t); %c,k (constant) and t(vector)
This will give you the desired vector.
Hope this helps in resolving your query.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!