Matlab and Vensim

Use this forum to post Vensim related questions.
Post Reply
Raquel
Junior Member
Posts: 7
Joined: Thu Jul 14, 2016 9:37 pm
Vensim version: DSS

Matlab and Vensim

Post by Raquel »

Hi,
I'm trying to call Vensim from Matlab and have gone quite far with the help of previous forum questions, yet I seem to have bumped into a new issue.

When loading the library in Matlab, I receive the following message:
"Warning: The function 'vensim_get_run_info' was not found in the library"

I have installed the 64-bit version of both Vensim and Matlab. Vensim was installed as an administrator.

Any suggestions?
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Matlab and Vensim

Post by Administrator »

How do you load the library? Do you pass a header file to Matlab?
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
Raquel
Junior Member
Posts: 7
Joined: Thu Jul 14, 2016 9:37 pm
Vensim version: DSS

Re: Matlab and Vensim

Post by Raquel »

Yes, I used a header file. The code I used was:

if not(libisloaded('VenDLL64'))
hfile = ['C:\Users\Public\Vensim\DLL\vendll.h'];
loadlibrary('VenDLL64',hfile);
end

It finds the library. The output message is:
Warning: The function 'vensim_get_run_info' was not found in the library
> In loadlibrary
In LoadVensimLibrary (line 3)
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Matlab and Vensim

Post by Administrator »

ok, if you edit the vendll.h file, comment out line 140 so that it changes from

Code: Select all

CFUNCTION int VEFCC vensim_get_run_info(char *strRunName, int nInfoWanted,char *strReceivingBuffer,int nMaxBufLen) ;
to

Code: Select all

//CFUNCTION int VEFCC vensim_get_run_info(char *strRunName, int nInfoWanted,char *strReceivingBuffer,int nMaxBufLen) ;
As long as you don't need that function, it should now work.
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
Raquel
Junior Member
Posts: 7
Joined: Thu Jul 14, 2016 9:37 pm
Vensim version: DSS

Re: Matlab and Vensim

Post by Raquel »

Yes, that solves the warning.
What exactly do I lose if I don't have this function?

Further issue:
When running the test code for the rabbit example the output looks strange. Here the beginning:

%rabbit example
str=['SPECIAL>LOADMODEL|RABFOX.vpmx'];
calllib('VenDLL64','vensim_check_status')
calllib('VenDLL64','vensim_command',str)
str=['MENU>RUN|o'];
calllib('VenDLL64','vensim_command',str)

ans =

6


ans =

1


ans =

1

Is this correct?
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Matlab and Vensim

Post by Administrator »

It looks correct. See the documentation at
http://www.vensim.com/documentation/26165.htm
and
http://www.vensim.com/documentation/26170.htm

A value of 6 for vensim_check_status indicates "to indicate that Vensim has not freed all of its working memory. Normally a call to vensim_command will correct this."

A value of 1 from the call to vensim_command indicates the command executed correctly.

I'd be interested if you could share your code to load the Vensim DLL into Matlab. Users ask regularly how to do it, but we don't have a copy of Matlab to experiment with.
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
Raquel
Junior Member
Posts: 7
Joined: Thu Jul 14, 2016 9:37 pm
Vensim version: DSS

Re: Matlab and Vensim

Post by Raquel »

Sure, I can share it! But the forum does not accept .m files attached. Is there another channel to send it?

Still, could you elaborate on what I'm missing by not being able to use the "vensim_get_run_info"?
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Matlab and Vensim

Post by Administrator »

The vensim_get_run_info function is internal to Vensim, it should not have made it into the vendll.h file.

You can email the Matlab code to vensim@vensim.com, I can then include the important parts with DSS so others can use it.
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
Raquel
Junior Member
Posts: 7
Joined: Thu Jul 14, 2016 9:37 pm
Vensim version: DSS

Re: Matlab and Vensim

Post by Raquel »

Thanks!
Post Reply