Page 1 of 1
Move variables and calculate it into a vector
Posted: Thu Dec 11, 2014 5:03 pm
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!
Re: Move variables and calculate it into a vector
Posted: Thu Dec 11, 2014 7:04 pm
by Administrator
Can you post the model you have been experimenting with? I do not understand what you are trying to do.
Re: Move variables and calculate it into a vector
Posted: Mon Dec 15, 2014 4:39 pm
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...
Re: Move variables and calculate it into a vector
Posted: Tue Dec 16, 2014 9:35 am
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?
Re: Move variables and calculate it into a vector
Posted: Tue Dec 16, 2014 2:11 pm
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.
Re: Move variables and calculate it into a vector
Posted: Tue Dec 16, 2014 3:07 pm
by Administrator
I've attached a model that does some of what you need (you will need to complete the rest).
Re: Move variables and calculate it into a vector
Posted: Tue Dec 16, 2014 4:20 pm
by luisangelguzmang
Thanks a lot!
Re: Move variables and calculate it into a vector
Posted: Tue Dec 16, 2014 10:02 pm
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
Re: Move variables and calculate it into a vector
Posted: Wed Dec 17, 2014 10:33 am
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.
Re: Move variables and calculate it into a vector
Posted: Wed Dec 17, 2014 2:29 pm
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.
Re: Move variables and calculate it into a vector
Posted: Thu Dec 18, 2014 2:41 pm
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.