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.

回答(1 个)

Arun
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.

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by