Period of variable signal

Use this forum to post Vensim related questions.
Post Reply
yusuke
Member
Posts: 48
Joined: Sun Apr 27, 2008 11:41 pm

Period of variable signal

Post by yusuke »

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
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

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.
yusuke
Member
Posts: 48
Joined: Sun Apr 27, 2008 11:41 pm

Post by yusuke »

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
Attachments
spanvalue.mdl
(2.2 KiB) Downloaded 287 times
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

The model does what I would expect it to. I think I do not understand what you want to see.
LAUJJL
Senior Member
Posts: 1477
Joined: Fri May 23, 2003 10:09 am
Vensim version: DSS

period of variable signal

Post by LAUJJL »

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
Attachments
spanvalue[2].mdl
(2.05 KiB) Downloaded 253 times
yusuke
Member
Posts: 48
Joined: Sun Apr 27, 2008 11:41 pm

Post by yusuke »

Thank you LAUJJL .
Your model spanvalue[2] is just one i need.

The using of equation <Time Step>/<Time Step> is effective for unit check.

I thank bob , too.
Post Reply