Hi,
I am trying to select and change only one element of an array which satisfies a certain condition even if there are several elements within this array which satisfy that condition. For example, I have the following array v=(-1,-1,0,0,0) in which two elements equal -1 (the condition). However, I only want to change one of the two elements which equal -1 to zero and leave the other unchanged (i.e., v'=(0,-1,0,0,0) or (-1,0,0,0,0)). How can I do this in Vensim?
Thanks a lot!
Change a specific element of an array
Re: Change a specific element of an array
Here's a way:
Note the subscript mapping of iPrev & iNext - this is the standard way to iterate over subscript elements./*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Re: Change a specific element of an array
That's a very nice and elegant way! Thanks a lot!