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.

Invoke parameters from comsol in matlab

Please login with a confirmed email address before reporting spam

Hi everyone,
I would like to invoke parameters from comsol in matlab, the code is as follows

model.param.set('N', '5');

num=model.param.N;

Error in num=model.param.N;

And how to invoke the parameter 'N' in matlab? Is there any other way to do this? Any help is appreciated.

1 Reply Last Post 2016年5月26日 GMT-4 07:53
COMSOL Moderator

Hello Zhikai Zhao

Your Discussion has gone 30 days without a reply. If you still need help with COMSOL and have an on-subscription license, please visit our Support Center for help.

If you do not hold an on-subscription license, you may find an answer in another Discussion or in the Knowledge Base.


Lars Gregersen COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 8 years ago 2016年5月26日 GMT-4 07:53
Hi

In recent versions of Comsol you can do:

[num,unit,expr] = mphevaluate(model, 'N');

which will evaluate the expression for N and returns the numerical value, unit and original definition. In your case it is just a number, but the expressions for parameters can of course be much more complicated than that.


In older versions of Comsol you have to do something like this:

expr = model.param.get('N');
and
value = model.param.evaluate('N')

mphevaluate handles complex parameters automatically. If your parameters are complex you have to use evaluateComplex instead of evaluate in the code above.


--
Lars Gregersen
Comsol Denmark
Hi In recent versions of Comsol you can do: [num,unit,expr] = mphevaluate(model, 'N'); which will evaluate the expression for N and returns the numerical value, unit and original definition. In your case it is just a number, but the expressions for parameters can of course be much more complicated than that. In older versions of Comsol you have to do something like this: expr = model.param.get('N'); and value = model.param.evaluate('N') mphevaluate handles complex parameters automatically. If your parameters are complex you have to use evaluateComplex instead of evaluate in the code above. -- Lars Gregersen Comsol Denmark

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.