vensim link matlab

Use this forum to post Vensim related questions.
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

It sounds like there is an inconsistency between vendll.h and the actually dll. The version you are using is too old for me to remember any such issues unfortunately.
ahmadi2010
Senior Member
Posts: 77
Joined: Thu Aug 19, 2010 3:34 pm

Post by ahmadi2010 »

Thank you bob,:(,:o
if I install Vensim Dss(Vensim 5.9b) on Win Xp, does it work with matlab correctly?

[Edited on 9-28-2010 by ahmadi2010]
Administrator
Super Administrator
Posts: 4590
Joined: Wed Mar 05, 2003 3:10 am

Post by Administrator »

Best thing to do is try it and see.
ahmadi2010
Senior Member
Posts: 77
Joined: Thu Aug 19, 2010 3:34 pm

Post by ahmadi2010 »

I used Micro & tried to run & simulate vensim from Excel. now I want for a mfile in matlab, call my excel program & run vensim model. How can I do?Can anyone help me?
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

You might try a Matlab forum for this question. I doubt if anyone who reads this forum to help you with invoking Excel from Matlab. Excel can be controlled using OLE so there is almost certainly a way to do it, but OLE is pretty complicated so it may not be easy.
ahmadi2010
Senior Member
Posts: 77
Joined: Thu Aug 19, 2010 3:34 pm

Post by ahmadi2010 »

Thank you bob,
I could solve it.but now I have 2 questions.

when I link vensim and excel, I use another excel file for my variable in vensim and in vensim I used it's adress, now I want to close automatically the data excel window after run micro and run vensim.what can I do?

another question:when I use for loop in micro to run vensim several times,after each run vensim ask me a question and I have to answer it to go to the next step Otherwise it will not go to the next stage.I dont want to see this window.what Can I do?

it's question:dataset current already exist. do you want to overwrite it?
Administrator
Super Administrator
Posts: 4590
Joined: Wed Mar 05, 2003 3:10 am

Post by Administrator »

>> when I link vensim and excel, I use another excel file for
>> my variable in vensim and in vensim I used it's adress, now I
>> want to close automatically the data excel window after run micro
>> and run vensim.what can I do?
This is all in Matlab code isn't it? You will need to ask on a Matlab forum for the answer.

>> another question:when I use for loop in micro to run vensim several
>> times,after each run vensim ask me a question and I have to answer
>> it to go to the next step Otherwise it will not go to the next stage.
>> I dont want to see this window.what Can I do?
There is a function you can call in the same way as vensim_command called vensim_be_quiet. Call this in your code and the box will not appear. But see the next answer as well before you do this.

>> it's question:dataset current already exist. do you want to overwrite it?
What is the command you are using to run the model? Is it "MENU>RUN|"? If it is, try "MENU>RUN|o" instead.

[Edited on 27-10-2010 by Administrator]
ahmadi2010
Senior Member
Posts: 77
Joined: Thu Aug 19, 2010 3:34 pm

Post by ahmadi2010 »

I'm using :

Sub Simulate()

Application.DDEExecute DDE_channel, "[MENU>RUN1|O]"

Application.Visible = True

End Sub
....................
and this table appears: Question from vensim!!!!!!!!!!!!

[Edited on 10-27-2010 by ahmadi2010]

[Edited on 10-27-2010 by ahmadi2010]
Administrator
Super Administrator
Posts: 4590
Joined: Wed Mar 05, 2003 3:10 am

Post by Administrator »

Try MENU>RUN|o and see if that solves the problem.
ahmadi2010
Senior Member
Posts: 77
Joined: Thu Aug 19, 2010 3:34 pm

Post by ahmadi2010 »

T try these:
Try MENU>RUN|O
Try MENU>RUN|o
Try MENU>RUN|0

But whenevev I run micro that table appears and I have to say yes to it. Is there any way that I manage it from inside of vensim program to automatically replace each new run to previos?
ahmadi2010
Senior Member
Posts: 77
Joined: Thu Aug 19, 2010 3:34 pm

Post by ahmadi2010 »

Thank you Tony:)

I find it by myself

In option table\setting I should select (overwrite(no query)).
ahmadi2010
Senior Member
Posts: 77
Joined: Thu Aug 19, 2010 3:34 pm

Post by ahmadi2010 »

now I have another question:

when I run micro, when it reach to the step that should show the result in the place that I specified for it in excel,for some of them this apears:--

But only somtimes.Do you know what is the reason??

[Edited on 10-28-2010 by ahmadi2010]

[Edited on 10-28-2010 by ahmadi2010]
Attachments

[The extension ocx has been deactivated and can no longer be displayed.]

bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

In Vensim -- means :NA: - I don't know what micro is, but it sounds like something might not have been computed.
ahmadi2010
Senior Member
Posts: 77
Joined: Thu Aug 19, 2010 3:34 pm

Post by ahmadi2010 »

after run micro,vensim has calculated and I can see the results in vensim but in excel I can't see it????

Sub GetValue()

Dim returnList As Variant


For i = 1 To 10

varstr$ = Cells(5, 8).Text + "@" + Str(i)

returnList = Application.DDERequest(DDE_channel, varstr$)

Cells(4 + i, 10).Value = returnList(LBound(returnList))
Cells(4 + i, 9).Value = i

Next


varstr$ = Cells(5, 12).Text

returnList = Application.DDERequest(DDE_channel, varstr$)

Cells(5, 13).Value = returnList(LBound(returnList))



varstr$ = Cells(5, 15).Text + "@" + Cells(5, 16).Text

returnList = Application.DDERequest(DDE_channel, varstr$)

Cells(5, 17).Value = returnList(LBound(returnList))



End Sub
....................................
for the first time after run I can see all the value that calculated by the vensim, but for the second and ....... that sign apears!!!!

[Edited on 10-28-2010 by ahmadi2010]
Attachments

[The extension ocx has been deactivated and can no longer be displayed.]

Administrator
Super Administrator
Posts: 4590
Joined: Wed Mar 05, 2003 3:10 am

Post by Administrator »

You will need to upload the model and spreadsheet for us to take a proper look. If you would prefer to email them to me direct I can take a look (tony@vensim.com).
ahmadi2010
Senior Member
Posts: 77
Joined: Thu Aug 19, 2010 3:34 pm

Post by ahmadi2010 »

I'm faced with a new event. I'm using micro like these:

sub load model()
.
.
end sub
..............
sub setconstant()
.
.
endsub
..............
sub simulate()
.
.
end
...........

and so

....................
when I run these micro by click on eachone steb by step,it works correctly.But when I record these micros and use one micro for running the program, I see (--) for some variable!!!!!!!!!!!!But I need to record and use one micro:(
Administrator
Super Administrator
Posts: 4590
Joined: Wed Mar 05, 2003 3:10 am

Post by Administrator »

There seems to be a DDE problem here.

Give me a short while and I'll generate an example using the Vensim DLL.

Tony.
Administrator
Super Administrator
Posts: 4590
Joined: Wed Mar 05, 2003 3:10 am

Post by Administrator »

I've replied to you via email.

Tony.
ahmadi2010
Senior Member
Posts: 77
Joined: Thu Aug 19, 2010 3:34 pm

Post by ahmadi2010 »

Thank you Tony for your help
ahmadi2010
Senior Member
Posts: 77
Joined: Thu Aug 19, 2010 3:34 pm

Post by ahmadi2010 »

Is there any way that vensim after its running automatically exports some calculated value to an excel environment. (with the settings before runnig program)?
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

You know you can call Vensim DSS by providing it with a .cmd script as an argument and have it do whatever you want, including exporting results to a txt file that Excel can read or pushing them to a database using ODBC that excel can also read. At the end of that a MENU>EXIT will cause the Vensim DSS process to exist and then you can start it again fresh the next time it is needed.
ahmadi2010
Senior Member
Posts: 77
Joined: Thu Aug 19, 2010 3:34 pm

Post by ahmadi2010 »

Thank you bob


1)I'm using this command (SPECIAL>LOADMODEL) for .mdl (DDE problem)
for .cmd script what kind of command should I use??

2)I'm using this command (MENU>EXIT ) to close vensim program. Is there any command to start vensim after closing it?
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

The commands are the same - so it is still SPECIAL>LOADMODEL - to launch Vensim you will need to ask on the Excel or Matlab forums.
samira15928
Junior Member
Posts: 16
Joined: Fri Jun 24, 2016 4:47 am
Vensim version: DSS

Re:

Post by samira15928 »

ahmadi2010 wrote:Finaly I could load vendll32.

Now I load this model:

str=['SPECIAL>LOADMODEL|',test,'.vpm'];
lp=libpointer('voidPtr',[int8(str) 0]);
calllib('vendll32','vensim_command',lp);

How can I see the result of my model in matlab or the amount of variable thet I defined in vensim?

You mean by installing XP, you solved the problem?
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Re: vensim link matlab

Post by tomfid »

This thread is six years old, and all the software involved has changed - I think you're unlikely to get useful answers here. I'd suggest composing a new question.
Post Reply