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!
Export data to Excel or something similar
-
- Senior Member
- Posts: 1107
- Joined: Wed Mar 12, 2003 2:46 pm
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?
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
Tom
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
-
- Super Administrator
- Posts: 4590
- Joined: Wed Mar 05, 2003 3:10 am
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.
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.
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.
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.
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
If I do this, it gives an error when I try to paste in excel. Only the time variable is copied...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.