Reputation: 321
In a parameter variation experiment I am plotting data from a dataset located in Main. Like this:
I use the following code to display data in the plot:
if(root.p_X == 7) {
plot.addDataSet(root.ds_waitTime,
"X = " + root.p_X,
transparent(red, 0.5), true, Chart.INTERPOLATION_LINEAR,
1, Chart.POINT_NONE);
else if(root.p_X == 14) {
plot.addDataSet(root.ds_waitTime,
"X = " + root.p_X,
transparent(red, 0.5), true, Chart.INTERPOLATION_LINEAR,
1, Chart.POINT_NONE);
My question is related to exporting the underlying data. I am not sure what the best way is to export the data. For each simulation run, I want to export dataset root.ds_waitTime
to a csv or excel file, annotated with the value of root.p_X == 14
. I know you can add datasets to a 2d histogram dataset, but this also transforms the data, so that doesn't seem a good option. Also, I do not have set up an external database, and I'd prefer not to.
Is it possible to save root.ds_waitTime
to column 1 and 2 for simulation run 1, to column 3 and 4 for simulation run 2, and so on?
Upvotes: 1
Views: 334
Reputation: 2213
In the Experiment window do the following:
Then, in the Experiment window properties under "Java Actions" in the field "After Simulation Run", use the following code (where dataSet is the name of your dataset):
excelFile.writeDataSet(dataSet, 1, 2, 1 + i*2);
i++;
This way, after each simulation run, the dataset is written to the next 2 rows.
The syntax I used refers to the:
For the header row, you can alternatively add the following code:
excelFile.setCellValue(dataset name, 1, 1, 1 + i*2);
Upvotes: 2