Please login with a confirmed email address before reporting spam
Posted:
9 years ago
21 mars 2016, 14:45 UTC−4
You can set 'table' in comsol so that you don't need to read from files. Here is the script that you may change in the *.m file:
% set interpolation function
model.func('int1').set('table', cellfun( @(x) num2str(x, '%0.10g'), num2cell( [y0, fy] ), 'UniformOutput', false));
where [y0, fy] is the two-column data that you stored in matlab. cellfun works as converting the data (mostly in double type ) into cells of string, so that comsol can read. In this way, you do not need to save data into the hard disk, but import directly from matlab to comsol.
By the way, unless you really have very large size of data, say ~GB, I don't think using the "files" option will be slow, since the FEM simulation usually consumes more time than data exchange between your hard drive and matlab.
You can set 'table' in comsol so that you don't need to read from files. Here is the script that you may change in the *.m file:
% set interpolation function
model.func('int1').set('table', cellfun( @(x) num2str(x, '%0.10g'), num2cell( [y0, fy] ), 'UniformOutput', false));
where [y0, fy] is the two-column data that you stored in matlab. cellfun works as converting the data (mostly in double type ) into cells of string, so that comsol can read. In this way, you do not need to save data into the hard disk, but import directly from matlab to comsol.
By the way, unless you really have very large size of data, say ~GB, I don't think using the "files" option will be slow, since the FEM simulation usually consumes more time than data exchange between your hard drive and matlab.
Please login with a confirmed email address before reporting spam
Posted:
9 years ago
21 mars 2016, 15:00 UTC−4
Thanks for the information.
I have been occupied with some other projects recently, and I will try it out as soon as I got some time.
Once again, thank you so much.
Thanks for the information.
I have been occupied with some other projects recently, and I will try it out as soon as I got some time.
Once again, thank you so much.
Please login with a confirmed email address before reporting spam
Posted:
9 years ago
22 mars 2016, 21:48 UTC−4
Dear Peng,
I think what you showed is how to pass 1-dimensional data back to Comsol? That is, fy = f(y0)?
What I want to know, is actually how to pass 2-dimensional data to Comsol, that is f(x,y) = f(x0,y0).
Do you know how to do this?
Thanks again,
Yadong
Dear Peng,
I think what you showed is how to pass 1-dimensional data back to Comsol? That is, fy = f(y0)?
What I want to know, is actually how to pass 2-dimensional data to Comsol, that is f(x,y) = f(x0,y0).
Do you know how to do this?
Thanks again,
Yadong
Please login with a confirmed email address before reporting spam
Posted:
9 years ago
25 mars 2016, 16:24 UTC−4
Dear Yadong,
Yes, for the multi-variable interpolation, the only way that I know is to use "import from file".
Peng
Dear Yadong,
Yes, for the multi-variable interpolation, the only way that I know is to use "import from file".
Peng
Please login with a confirmed email address before reporting spam
Posted:
9 years ago
25 mars 2016, 16:27 UTC−4
Ok, I see.
Thanks anyway!
Yadong
Ok, I see.
Thanks anyway!
Yadong
Please login with a confirmed email address before reporting spam
Posted:
9 years ago
16 mai 2016, 08:14 UTC−4
Hi all!
I found the solution very interesting as it is what I would need. Unfortunately, my MATLAB script does not replace the orders in the .m functions exported from COMSOL...
I need to replace the initial interpolation file established as a global definition. However, when I replace the corresponding line in the script, to add/import a new table, when running, it does not account for it and it runs according to the previous file. It seems like I am not able to overcome the first instructions from COMSOL and the default orders prevail.
I am trying to replace this line (a certain injection rate "q" over a time series, q(t):
model.func('int2').set('table', {'0' '0'; '600' '40'; '1200' '40'; '1800' '40'; '2400' '40'});
with this one:
model.func('int2').set('table', cellfun( @(x) num2str(x, '%0.10g'), num2cell([t, q_t]), 'UniformOutput', false));
I am sure there is something I am missing... I just cannot figure it out where... Maybe some of you could propose a solution! :)
Thanks!
Maria
Hi all!
I found the solution very interesting as it is what I would need. Unfortunately, my MATLAB script does not replace the orders in the .m functions exported from COMSOL...
I need to replace the initial interpolation file established as a global definition. However, when I replace the corresponding line in the script, to add/import a new table, when running, it does not account for it and it runs according to the previous file. It seems like I am not able to overcome the first instructions from COMSOL and the default orders prevail.
I am trying to replace this line (a certain injection rate "q" over a time series, q(t):
model.func('int2').set('table', {'0' '0'; '600' '40'; '1200' '40'; '1800' '40'; '2400' '40'});
with this one:
model.func('int2').set('table', cellfun( @(x) num2str(x, '%0.10g'), num2cell([t, q_t]), 'UniformOutput', false));
I am sure there is something I am missing... I just cannot figure it out where... Maybe some of you could propose a solution! :)
Thanks!
Maria