Dear all,
while using the COMSOL -MATLAB LiveLink, and in particular Matlab functions within COMSOL, I experienced some problems. I hope someone in this forum, has some experience about it and could help me.
First, do you know, whether it is possible to pass a string variable to a MATLAB function that is defined in COMSOL?
If I try that in a simple test model with a simple MATLAB function, I get the following error:
--
Evaluation of result expression failed
Strings are only allowed in function arguments
--
I attached the test-model and the function that I tried. Their names are question1.mph and question1.m. The function is called in the plot of the results section. It should, just as a test, return the first argument, if the second is a string 'on' and 0 otherwise.
At the end I would like to use this to pass variable names or paths to my MATLAB functions.
Second, could a MATLAB function, used in COMSOL, connect to a COMSOL server (for example using mphstart)?
For that I need two models, one where the MATLAB function should be executed and a second one that the MATLAB function tries to open, evaluate something and then return values to the original COMSOL model.
I attached a model question2.mph, a MATLAB function question2.mph and another model question2_dependency.mph, which is needed by the MATLAB function. The path within the MATLAB function should be changed to the folder where the dependency model is stored, a Comsol Server has to be opened and the port number should be adjusted in the MATLAB file.
If I try the function that I attached, I can see in the Servers window that a client connects to it (so far so good), but then I get the following error:
--
Evaluation of result expression failed.
Error using mphstart (line 152)
A connection to Comsol could not be established. Please check that a Comsol Server is started prior to calling mphstart
- Function: question2
- Plot: surf1 (Surface)
--
The test function should at the moment do nothing, but return the x value of a point on x,y,z since, the two models are actually so far the same. At the end I would like to use this to evaluate data together with other data from a completely different simulation model.
Thank you already in advance for your help.
Best regards,
Hannes
while using the COMSOL -MATLAB LiveLink, and in particular Matlab functions within COMSOL, I experienced some problems. I hope someone in this forum, has some experience about it and could help me.
First, do you know, whether it is possible to pass a string variable to a MATLAB function that is defined in COMSOL?
If I try that in a simple test model with a simple MATLAB function, I get the following error:
--
Evaluation of result expression failed
Strings are only allowed in function arguments
--
I attached the test-model and the function that I tried. Their names are question1.mph and question1.m. The function is called in the plot of the results section. It should, just as a test, return the first argument, if the second is a string 'on' and 0 otherwise.
At the end I would like to use this to pass variable names or paths to my MATLAB functions.
Second, could a MATLAB function, used in COMSOL, connect to a COMSOL server (for example using mphstart)?
For that I need two models, one where the MATLAB function should be executed and a second one that the MATLAB function tries to open, evaluate something and then return values to the original COMSOL model.
I attached a model question2.mph, a MATLAB function question2.mph and another model question2_dependency.mph, which is needed by the MATLAB function. The path within the MATLAB function should be changed to the folder where the dependency model is stored, a Comsol Server has to be opened and the port number should be adjusted in the MATLAB file.
If I try the function that I attached, I can see in the Servers window that a client connects to it (so far so good), but then I get the following error:
--
Evaluation of result expression failed.
Error using mphstart (line 152)
A connection to Comsol could not be established. Please check that a Comsol Server is started prior to calling mphstart
- Function: question2
- Plot: surf1 (Surface)
--
The test function should at the moment do nothing, but return the x value of a point on x,y,z since, the two models are actually so far the same. At the end I would like to use this to evaluate data together with other data from a completely different simulation model.
Thank you already in advance for your help.
Best regards,
Hannes