Move variables and calculate it into a vector

Use this forum to post Vensim related questions.
Post Reply
luisangelguzmang
Member
Posts: 42
Joined: Wed Apr 06, 2011 8:20 am

Move variables and calculate it into a vector

Post by luisangelguzmang »

Hi, i'm trying to move variables over time into a vector, but i can´t. For example, I get a subscript i, so my vector Xi is [7 2 5 4 8 0 0 0] in t=0 (get from excel). In t=1, I need to get a new vector X'i = [0 2 5 4 8 3 0 0], for t=2, [0 0 5 4 8 3 9 0] and so on. First question: can you help me to do this?
Second cuestion: in the last postion of these vectors (no zero) I need to make some calculations. I mean, in t=1, I need to calcultate the 3 and in the same way, in t=2 the 9. In summary, I have to calculate just one value in the vector and put in a specific position.
Thanks a lot!
Administrator
Super Administrator
Posts: 4838
Joined: Wed Mar 05, 2003 3:10 am

Re: Move variables and calculate it into a vector

Post by Administrator »

Can you post the model you have been experimenting with? I do not understand what you are trying to do.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
luisangelguzmang
Member
Posts: 42
Joined: Wed Apr 06, 2011 8:20 am

Re: Move variables and calculate it into a vector

Post by luisangelguzmang »

Hi, this is a post of my model (in Excel). I would like to reproduce this Excel model in Vensim. My starting point (t=0) is the column B (in yellow). The column A shows the subscripts.
Then, i need to calculate in the next iterations (t=1, 2,...n) the column values shown in the Excel file.
It is possible to do this en Vensim?
Thanks again...
Attachments
Vectors.xlsx
(20.95 KiB) Downloaded 788 times
Administrator
Super Administrator
Posts: 4838
Joined: Wed Mar 05, 2003 3:10 am

Re: Move variables and calculate it into a vector

Post by Administrator »

That spreadsheet has no equations in it.

Are you trying to import this as data in Vensim? Or are you trying to replicate the values?
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
luisangelguzmang
Member
Posts: 42
Joined: Wed Apr 06, 2011 8:20 am

Re: Move variables and calculate it into a vector

Post by luisangelguzmang »

Sorry, wrong file. I'm trying to replicate the values. My starting vector is the column B (yellow) and from this point (t=0) I need to replicate the values of the following columns.
Thanks.
Attachments
Vectors.xlsx
(37.18 KiB) Downloaded 833 times
Administrator
Super Administrator
Posts: 4838
Joined: Wed Mar 05, 2003 3:10 am

Re: Move variables and calculate it into a vector

Post by Administrator »

I've attached a model that does some of what you need (you will need to complete the rest).
Attachments
demo.mdl
(2.94 KiB) Downloaded 913 times
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
luisangelguzmang
Member
Posts: 42
Joined: Wed Apr 06, 2011 8:20 am

Re: Move variables and calculate it into a vector

Post by luisangelguzmang »

Thanks a lot!
luisangelguzmang
Member
Posts: 42
Joined: Wed Apr 06, 2011 8:20 am

Re: Move variables and calculate it into a vector

Post by luisangelguzmang »

One more question: how can change the last value (position) of each array with a new customized calculation?
I mean, if I have the following array V=[1 4 3 6 2 8] in t=0, I need in t=1, calculate a new array V*= [14 3 6 2 8*2], for t=2, V**= [1 4 3 6 2 16*0.6] and so on.
How can I do this in Vensim?
Thks again
Administrator
Super Administrator
Posts: 4838
Joined: Wed Mar 05, 2003 3:10 am

Re: Move variables and calculate it into a vector

Post by Administrator »

You will need to use an IF THEN ELSE statement (something like "if then else ( subscript_range = xxxx , y,z)". See the equation for "outflow" for something similar.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
luisangelguzmang
Member
Posts: 42
Joined: Wed Apr 06, 2011 8:20 am

Re: Move variables and calculate it into a vector

Post by luisangelguzmang »

Yes, but the point is that I need to use the last value of of the previous vector. Again, in t=0, V=[1 4 3 6 2 8], so in t=1, my new array will be V*= [14 3 6 2 8*2], using the last position, e.g. the eight (8) value from V. My problem is that I can not (I don't know how) use this value (in this case, the eigth).
Thks.
Administrator
Super Administrator
Posts: 4838
Joined: Wed Mar 05, 2003 3:10 am

Re: Move variables and calculate it into a vector

Post by Administrator »

The attached model has a value that corresponds to the last value in the vector. You could use this with an IF THEN ELSE to change the calculation.
Attachments
demo.mdl
(3.39 KiB) Downloaded 847 times
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
Post Reply