Page 1 of 1

tabbed array

Posted: Mon Jan 31, 2005 4:29 pm
by sintef
i tried to use tabbed array by following the example in the manuals, but it did not work. can anyone provide me an example with two subscripts?

Reply tab array

Posted: Tue Feb 01, 2005 9:55 am
by LAUJJL
Hi

First you nedd to have at least Vensim Pro, as other lower versions do not use subscripts.

I tried to construct arrays the way it is explained in the documentation.
I have never used it that way.
In fact I think that this feature is used only for pasting data from spreadsheet as if you try to use the tabulation key in the editor, it does not seem to work.
You only have to put the data in a spreadsheet in the correct order and to copy (Ctrl C) and to paste it (Ctrl V) when in the editor of Vensim.
I have joined one Vensim model, and the corresponding excel spreadsheet.
Regards.
J.J. Laublé

Vensim model for tabbed array

Posted: Tue Feb 01, 2005 9:56 am
by LAUJJL

Posted: Tue Feb 01, 2005 11:43 pm
by sintef
thank you very much indeed

Re: tabbed array

Posted: Wed Mar 02, 2011 1:05 pm
by Junaid
Hi,

I have copied and pasted values from an Excel sheet but still this function does not work. I am using it exactly like this in Vensim Professional:

TABBED ARRAY( 24
26
27 )

I am using these 24, 26, and 27 values as the time parameter for PULSE function, i.e., 200 * PULSE (Tabbed_Array, 5). I am attaching the model. The tabbed array function is used in "Sampling at Time" variable.

Can someone please look into this issue and provide some guidance?

Thanks,

Junaid

Re: tabbed array

Posted: Wed Mar 02, 2011 1:57 pm
by Administrator
Follow the instructions in the help system and it works fine.

subsc : (sub1-sub3)

SAMPLING AT TIME[subsc] = TABBED ARRAY ( 24 26 27 )

Re: tabbed array

Posted: Thu Mar 03, 2011 12:32 pm
by Junaid
I looked into the help example and I tried to follow how you used it, but I am still unable to understand how this function works.


subsc : (sub1-sub3) // What does this line mean? Is "subsc" another variable? What is "sub1-sub3" representing?

Sampling at Time[subsc] = TABBED ARRAY ( 24.7 // Are we passing "subsc" to "Sampling at Time"?
26
27.3)
)

Can you please elaborate a little more?

Re: tabbed array

Posted: Thu Mar 03, 2011 3:45 pm
by tomfid
What are you trying to do with your Sampling at Time variable? You don't have any subscripts in your model, so it's not going to work as is. It looks like you're after essentially a time series of pulses. If the pulses are regularly spaced, you can use PULSE TRAIN. If not, the simplest thing would probably be to replace
PULSE ( Sampling at Time , 0.0083 )
with
(PULSE ( Sampling Time 1, 0.0083 )+PULSE ( Sampling Time 2, 0.0083 )+PULSE ( Sampling Time 3, 0.0083 ))
also it would be good to make your .0083 duration into an explicit parameter (= Sampling Duration?).

I notice that your time step (.001s) is very small for a 40s model run time. Presumably this is because the sampling duration is short - does it need to be that short? Also, you'll get better numerical precision if your time step is a power of two, like 0.0078125.

Re: tabbed array

Posted: Thu Mar 03, 2011 4:37 pm
by Junaid
Thank you for looking into this issue, Tom.

Yes, I am after a time series of pulses, but an irregular one. I previously thought to use the pulse function in the way you have suggested, i.e., adding up a number of pulses. However, I have around 40 pulses, which means that I would need 40 different variables to implement it that way. I wonder how I can do it in some elegant way; a tool as powerful as Vensim must be having some better technique! I do not want to read the data from an Excel sheet either as I want my model to be a stand alone file without any Excel sheets following it everywhere. Now the question remains: is there some better way to incorporate a simple series (array of values) in Vensim? I can do it with a lookup too but isn't it even more clumsy for an academic model?

Thanks for suggesting a variable for the pulse duration instead of repeating 0.0083 all the way; I am surely going to make that change.

Re: tabbed array

Posted: Thu Mar 03, 2011 7:25 pm
by tomfid
I think the cleanest thing to do would be to use an array.

Create a subscript:

pulses : (p1-p40)

Define your times:

sample time[pulses] = 24,26,27, ...

Aggregate the pulses:

sample switch = SUM( PULSE(sample time[pulses!], duration) )

Then use the sample switch in place of the pulse you now have in O2 Sampling Loss.

Re: tabbed array

Posted: Mon Mar 14, 2011 4:15 pm
by Junaid
This was very helpful, indeed. I've managed to get what I wanted. Thank you very much, Tom!