Page 1 of 1
How to convert a pulse of magnitude (x), width 1 into a puls
Posted: Tue Dec 11, 2007 9:27 am
by nikvyas
Good morning Bob, JJ, all.
I have another query that I'd be very grateful to have some assistance with.
I have a function that has created a series of pulses of varying heights. What I need to do is to convert these pulses of height (x) into pulses of width (x). For instance:
convert:
input= 500000000200000060000000000200000
into:
output=111110000110000011111100000110000
However, if the pulses in "input" are close enough, they will add up. For instance:
convert:
input= 5002004602000060000000
into:
output:111220122321101111100
Thanks very much in advance.
Nik
Posted: Tue Dec 11, 2007 12:05 pm
by bob@vensim.com
I am pretty sure this was discussed before - have you searched the archives?
The simple answer is
active = IF THEN ELSE(pending > 0,1,0)
pending = INTEG(pulse height-active,0)
[Edited on 2007-12-11 by
bob@vensim.com]
Posted: Tue Dec 11, 2007 1:17 pm
by nikvyas
Thanks Bob - however.....................................
The following situation isn't captured in your equations (where pulses close together will add up):
convert:
input= 5002004602000060000000
into:
output:111220122321101111100
i.e. - if you consider each of the pulses in "input" to be the number of hours an aircraft needs to undergo corrective maintenance, you will see that there are 5 aircraft (at t=1, t=4, t=7, t=8, t=10, t=15). What I am trying to achieve, is to look at the number of aircraft that are undergoing corrective maintenance at any particular period of time - that is why I am turning the magnitude (in "input") into a pulse width (in "output"). So for instance at t=4 & t=5 (in "output"), we have 2 a/c undergoing corrective maintenance etc. This is because the first a/c (magnitude 5 in "input") will be undergo maintenance at t=1, t=2, t=3, t=4, t=5 whereas the second a/c (magnitude 2 in "input") will undergo maintenance at t=4, t=5.
Hope this is clear Bob.
Thanks
Nik
[Edited on 12-11-2007 by nikvyas]
Posted: Tue Dec 11, 2007 5:01 pm
by bob@vensim.com
the only way I can think to do this is pretty brute force
insize : (i1-i10)
output = SUM(output by input[insize!])
input by insize[insize] = IF THEN ELSE(input = insize,insize,0)
output by insize[insize] = IF THEN ELSE(accum by insize[insize] > 0,1,0)
accum by insize[insize] = INTEG(input by insize[insize] - output by insize[insize],0)
insize must be at least as big as the largest value input can take on. This should, possibly with some tweaking, work.
Posted: Tue Dec 11, 2007 5:03 pm
by bob@vensim.com
not quite - maybe this will work
insize : (i1-i10)
output = SUM(output by input[insize!])
input by insize[insize] = IF THEN ELSE(input = insize,insize,0)
output by insize[insize] = DELAY CONVEYOR(input by insize[insize],insize,0,flat,0,1)
still you may need to play around.
[Edited on 2007-12-11 by
bob@vensim.com]
Posted: Wed Dec 12, 2007 8:30 am
by nikvyas
Thanks Bob...................although I'm really struggling to understand the equations I'm afraid. Could you please let me know the equation for "ouput by input" please (maybe you could attach a tiny model

)?
Thanks
Nik
[Edited on 12-12-2007 by nikvyas]
Posted: Wed Dec 12, 2007 12:26 pm
by bob@vensim.com
Sorry - sum should be
output = SUM(output by insize[insize!])
Posted: Fri Dec 14, 2007 9:53 am
by nikvyas
Thanks Bob.
Unfortunately it doesn't really work very well, so I've decided that the best option is to change the structure of the model, so that the pulses are now elements of a subscript and I've ensured that the pulses in each element have no chance of "running" into each other. I then simply SUM all the pulses at the end.
Nik