Dynamic variable

Clear all

# Dynamic variable

3 Posts
4 Users
1 Likes
871 Views
Posts: 1
Customer
Topic starter
(@0ojhfmwqgjrglyp46x5qoeo0jgg2)
New Member
Joined: 1 year ago

Dear Analytical users,

I am newbe.

If I define inv_t as:

Dynamic[i_t](inv_0,Self[i_t-1]-dem_t[i_t]+lambda[i_t])

And i_t as:

1 .. 365

I will obtein in inv_t as

first value

inv_0

inv_0

second value

inv_0 - dem_t[1] + lambda[1]

or second value is

inv_0 - dem_t[2] + lambda[2]

SebastiÃ¡n.

2 Replies
Posts: 38
(@lchrisman)
Member
Joined: 13 years ago

The second value will be

inv_0 - dem_t[1] + lambda[1]Â

Let's take some example values:

Inv_0 := 100000
Dem_t := 10 * I_t
Lambda := 100 * I_t

The result sequence will be:

100000
100000 + 200 - 20 = 100180
100180 + 300 - 30 = 100450
100450 + 400 - 40 = 100810
...

By the way, if you prefer writing dem_t[I_t] then that is fine, but the [I_t] part is not doing anything since variable names in a Dynamic automatically use the current time slice.Â  So it is entirely equivalent to write

Dynamic[i_t](inv_0, Self[i_t-1] - dem_t + lambda)

Â My own preference is to not include the extra subscript notation.

Posts: 3
Customer
(@xlptf79tizl550gfep8lo6isp6t2)
Active Member
Joined: 3 years ago

In a Dynamic, the notation X[I_t - k] is by position, not by value. So this notation is an abbreviated for X[@I_t = @I_t - k].Â  In general, this is not the same as X[ I_t = I_t - k ] nor X[ @I_t = I_t - k ].Â

Since positions are numbered starting at 1, positional and associative subscripts are the same in your example where you haveÂ

Index I_t := 1..365

Index I_t := 0..364