Hello
I'm using vensim professional version.
I make a variable which has a signal "0" or "1".
For example (starttime =1 , endtime =10)
time 1 2 3 4 5 6 7 8 9 10
var 0 0 0 1 1 1 1 1 0 0
I want to get the period which var = 1.
In this case , time(8) - time(4)+1=5
It is the same of the count which var(value) =1
Thank you for your help.
Yusuke Tarumoto
Period of variable signal
-
- Senior Member
- Posts: 1107
- Joined: Wed Mar 12, 2003 2:46 pm
The period of time since a variable last changed can be computed using
time unchanged = Time - last change time
last change time = SAMPLE IF TRUE(ABS(var-old var) > tolerance, var,Time,INITIAL TIME)
old var = SMOOTH(var,TIME STEP)
This will start counting again from 0 when the variable changes, so I am not sure if that is exactly what you want.
time unchanged = Time - last change time
last change time = SAMPLE IF TRUE(ABS(var-old var) > tolerance, var,Time,INITIAL TIME)
old var = SMOOTH(var,TIME STEP)
This will start counting again from 0 when the variable changes, so I am not sure if that is exactly what you want.
Thank you ,Bob.
I try to use [SAMPLE IF TRUE] function in a model.
But I can't. My troble is [last change time].
> last change time = SAMPLE IF TRUE(ABS(var-old var) > tolerance, var,Time,INITIAL TIME)
I attach a sample model .
Best regards
I try to use [SAMPLE IF TRUE] function in a model.
But I can't. My troble is [last change time].
> last change time = SAMPLE IF TRUE(ABS(var-old var) > tolerance, var,Time,INITIAL TIME)
I attach a sample model .
Best regards
- Attachments
-
- spanvalue.mdl
- (2.2 KiB) Downloaded 287 times
-
- Senior Member
- Posts: 1107
- Joined: Wed Mar 12, 2003 2:46 pm
period of variable signal
Hi
If I understand what you want (hence the utility of being clear about what one wants), you are interested in knowing the number of periods where var is equal to 1?
If it is what you want, the model joined is extremely simple and does the job.
Regards.
JJ
If I understand what you want (hence the utility of being clear about what one wants), you are interested in knowing the number of periods where var is equal to 1?
If it is what you want, the model joined is extremely simple and does the job.
Regards.
JJ
- Attachments
-
- spanvalue[2].mdl
- (2.05 KiB) Downloaded 253 times