Initializing a variable using Matlab

Use this forum to post Vensim related questions.
Post Reply
olive
Member
Posts: 22
Joined: Tue Sep 13, 2011 8:30 pm

Initializing a variable using Matlab

Post by olive »

Good evening,
I would like to run the same model under a different set of initial variables.
I have a variable 'Number of arriving aircraft' of Type Level-Normal. Its equation is INTEG(Annual traffic increase) and its initial value is a gaming variable called 'Initial Number of arriving aircraft'.
I'm trying to pass a value for 'Initial Number of arriving aircraft' at the same time i'm defining the final time of the simulation (See below) but I cannot get it to work. When it runs the model uses the value by default in the model and not the one i'm passing it.

Code: Select all

comstr3 = ['SIMULATE>SETVAL|FINAL TIME =', num2str(FinalTime)];
calllib('VenDLL32','vensim_command',comstr3);
InitAC = 50;
comstr2 = ['SIMULATE>SETVAL|Initial Number of arriving aircraft = ', num2str(InitAC)];
calllib('VenDLL32','vensim_command',comstr2);
The sequence I used is the following:
Load the model and pass values for FINAL TIME and 'Initial Number of arriving aircraft
then SIMULATE>RUNNAME
then GAME>GAMEINTERVAL
then MENU>GAME
then I pass values for other variables of interest
then GAME>GAMEON
Then I retrieve values for other variables and plot them
and eventually GAME>ENDGAME.

Could somebody help me find out what I'm doing wrong?
Thank you very much for your help!
Kind regards,
Olivia
tomfid
Administrator
Posts: 3999
Joined: Wed May 24, 2006 4:54 am

Re: Initializing a variable using Matlab

Post by tomfid »

I think you want to leave your 'Initial Number of arriving aircraft' as an ordinary variable rather than a gaming variable, and set it with a SETVAL before you start the game with MENU>GAME.

Tom
olive
Member
Posts: 22
Joined: Tue Sep 13, 2011 8:30 pm

Re: Initializing a variable using Matlab

Post by olive »

Yes it works :) I set 'Number of arriving aircraft' as CONSTANT.
Thank you very much,
Olivia
Post Reply