Export data to Excel or something similar

Use this forum to post Vensim related questions.
Post Reply
Mattes_01
Member
Posts: 42
Joined: Mon Jul 05, 2010 6:05 am

Export data to Excel or something similar

Post by Mattes_01 »

Hello @ all.

Again, I am having a question:

I want to export the data from a simulation to Excel to calculate some optimization with MATLAB.

Unfortunately I cannot find any option to export the data.
The help says there should be an export button (even for PLE) but I cannot find it.

If it is not possible to do that with my version, is there another way (maybe a bit mor complicated one) to do that, because this optimization is important for me.

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

Post by bob@vensim.com »

Use the table tool to display the variables you are interested in the, then click on the export button (or use Edit>Copy/Ctrl+c) then in Excel use Edit>Paste/Ctrl+V. For PLE Plus and higher there is a Model>Export Dataaset command as well.
Mattes_01
Member
Posts: 42
Joined: Mon Jul 05, 2010 6:05 am

Post by Mattes_01 »

Correct!

Thank you, so obviously :)

And yes, I thouught so, that the export button is only available for the other versions.
Regards from germany

[Edited on 8-10-2010 by Mattes_01]
khalediwm
Member
Posts: 42
Joined: Sun Mar 07, 2010 9:58 am

Post by khalediwm »

I want to export, part of my model result (continuously) to a text/Excel file, in every step of my calculation, so that value can be used by another program. I know how to export data after the simulation, but I need to know how to do the same thing during the simulation period. Can anybody please help me?
tomfid
Administrator
Posts: 3808
Joined: Wed May 24, 2006 4:54 am

Post by tomfid »

I think you'd have to write an external function to write the data to text. Fairly simple, but a lot of overhead to get started.

Tom
khalediwm
Member
Posts: 42
Joined: Sun Mar 07, 2010 9:58 am

Post by khalediwm »

Thanks tomfid,
If any body has already done it, then please let me have a chance to look at your external library.
Administrator
Super Administrator
Posts: 4589
Joined: Wed Mar 05, 2003 3:10 am

Post by Administrator »

Do you have DSS? External functions are only available to DSS.

There is a sample C++ project that comes with Vensim, this is the best place to start.
khalediwm
Member
Posts: 42
Joined: Sun Mar 07, 2010 9:58 am

Post by khalediwm »

Yes, I am using Vensim5.10a DSS. I am having problem in writing anything within the vensim external function. It's not same as writing in C++, as I need to know the correct place to insert that code. If possible, can I please have a *.DLL file which can export data from Vensim to a text or xls file, during the simulation period?

it could be like below:

tt=exportvar (variable1, variable2,.., filename)

so, if I just call the function and mention required variables along with filename, then the model will be creating a file and will pass those values continuously.
tomfid
Administrator
Posts: 3808
Joined: Wed May 24, 2006 4:54 am

Post by tomfid »

It's a little more complicated than that. Take a look at venext.c in your Vensim comp directory.

Your function could be almost as simple as the COSINE function example, if you're only writing one variable to a static output file. You'd still have to add some logic to open & close the file in simulation_setup and simulation_shutdown.

If you need anything more than that, you'd probably want to use MYALLTYPES as a template.

In your model, you'd either have to call the logging function once for each variable exported, or perhaps construct an array of all the values and pass that to your function.
walin
Junior Member
Posts: 15
Joined: Mon Jul 05, 2010 11:59 am

Post by walin »

Originally posted by bob@vensim.com
Use the table tool to display the variables you are interested in the, then click on the export button (or use Edit>Copy/Ctrl+c) then in Excel use Edit>Paste/Ctrl+V. For PLE Plus and higher there is a Model>Export Dataaset command as well.
If I do this, it gives an error when I try to paste in excel. Only the time variable is copied...
Post Reply