tabbed array

Use this forum to post Vensim related questions.
Post Reply
sintef
Member
Posts: 21
Joined: Mon Nov 15, 2004 7:52 pm

tabbed array

Post 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?
LAUJJL
Senior Member
Posts: 1477
Joined: Fri May 23, 2003 10:09 am
Vensim version: DSS

Reply tab array

Post 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é
Attachments
tabbed_array.xls
(13.5 KiB) Downloaded 1087 times
LAUJJL
Senior Member
Posts: 1477
Joined: Fri May 23, 2003 10:09 am
Vensim version: DSS

Vensim model for tabbed array

Post by LAUJJL »

Attachments
tabbed_array.mdl
(1.2 KiB) Downloaded 1066 times
sintef
Member
Posts: 21
Joined: Mon Nov 15, 2004 7:52 pm

Post by sintef »

thank you very much indeed
Junaid
Member
Posts: 24
Joined: Thu Jan 27, 2011 10:53 am

Re: tabbed array

Post 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
Attachments
v.3.mdl
(7.82 KiB) Downloaded 671 times
Administrator
Super Administrator
Posts: 4848
Joined: Wed Mar 05, 2003 3:10 am

Re: tabbed array

Post 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 )
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
Junaid
Member
Posts: 24
Joined: Thu Jan 27, 2011 10:53 am

Re: tabbed array

Post 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?
tomfid
Administrator
Posts: 4005
Joined: Wed May 24, 2006 4:54 am

Re: tabbed array

Post 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.
Junaid
Member
Posts: 24
Joined: Thu Jan 27, 2011 10:53 am

Re: tabbed array

Post 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.
tomfid
Administrator
Posts: 4005
Joined: Wed May 24, 2006 4:54 am

Re: tabbed array

Post 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.
Junaid
Member
Posts: 24
Joined: Thu Jan 27, 2011 10:53 am

Re: tabbed array

Post by Junaid »

This was very helpful, indeed. I've managed to get what I wanted. Thank you very much, Tom!
Post Reply