Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.

importing data to a function (Application Builder)

Please login with a confirmed email address before reporting spam

I have a 2D model where I have two transient study steps. After one study step I evaluate a variable at a single point and export it into a file. (This file contains tabulated data with two columns (time and the value of the variable at that time)). Next, I import the same file into an "Interpolation function" which is used for the second transient study.

I want to create a COMSOL app to do this task. I created two buttons and attached two methods to perform the tasks. I used "record method" to perform each task manually and recorded the commands to methods. Exporting data method works fine without any issues. However my import data method contains the data values of the variable, rather than the path of the file i'm importing. Now even if I have new data in the file, method always puts the same data (that are already in the method) into my interpolate function.

Part of the Export Method:
---------------------------------------------------
with(model.result().export("tbl1"));
set("filename", "<path of the file>");
endwith();
---------------------------------------------------

Part of the Import Method:
---------------------------------------------------
"
with(model.func("int1"));
set("funcname", "name");
set("table", new String[][]{{"0", "1.38"}, {"0.1", "6.94"}, {"0.2", "-9.16"}, {"0.3", "-4.58"}, {"0.4", "-1.55"},....
---------------------------------------------------
"

Is there a way to put data into an interpolate function using a file so that the method always reads the file and grab the data.

I hope my question was not too confusing and I explained my concern clearly.

Thank You,
Saliya

1 Reply Last Post 3 feb 2016, 23:40 GMT-5

Please login with a confirmed email address before reporting spam

Posted: 8 years ago 3 feb 2016, 23:40 GMT-5
I've figured it out. Originally my data source was set to "table". It works when I change it to "file".
I've figured it out. Originally my data source was set to "table". It works when I change it to "file".

Note that while COMSOL employees may participate in the discussion forum, COMSOL® software users who are on-subscription should submit their questions via the Support Center for a more comprehensive response from the Technical Support team.