I have defined an external function in matlab that I use in my Comsol/Matlab livelink model to set a volume heat source, let's call this function my_heat(x,y,z), where x,y,z are comsol spatial variables.
Everything works fine with this (comsol passes x,y,z vectors and matlab returns heat source values based on this, and the model is set up and solved)
Now, I tried to use some global MATLAB variables within the 'my_heat' function. When I run function in MATLAB the variables and their values are accessible in 'my_heat'. However, when the same function is called by COMSOL as part of setting the physics, it seems 'my_heat' does not recognize these variables.
I think I know what the problem is, but don't know the solution to it:
When the model is run from Matlab, Comsol seem to open another instance of MATLAB (as manifested by a second command window). This seems like the place where all the Comsol/Matlab interfacing happens. No wonder that in this new instance of Matlab, the information about any global variables in the main Matlab window is missing.
Any ideas on how to 'pass' all the info from the main Matlab window to this auxiliary one?
Thanks,
Robert
P.S.: On an unrelated note, I discovered that by typing 'clear functions' in this new matlab window, I can have comsol get the updated version of any edits to my matlab fuinctions. Without this, comsol only has the first version of external functions. Typing 'clear functrions' in the main matlab window doesn't maker any difference.
Everything works fine with this (comsol passes x,y,z vectors and matlab returns heat source values based on this, and the model is set up and solved)
Now, I tried to use some global MATLAB variables within the 'my_heat' function. When I run function in MATLAB the variables and their values are accessible in 'my_heat'. However, when the same function is called by COMSOL as part of setting the physics, it seems 'my_heat' does not recognize these variables.
I think I know what the problem is, but don't know the solution to it:
When the model is run from Matlab, Comsol seem to open another instance of MATLAB (as manifested by a second command window). This seems like the place where all the Comsol/Matlab interfacing happens. No wonder that in this new instance of Matlab, the information about any global variables in the main Matlab window is missing.
Any ideas on how to 'pass' all the info from the main Matlab window to this auxiliary one?
Thanks,
Robert
P.S.: On an unrelated note, I discovered that by typing 'clear functions' in this new matlab window, I can have comsol get the updated version of any edits to my matlab fuinctions. Without this, comsol only has the first version of external functions. Typing 'clear functrions' in the main matlab window doesn't maker any difference.