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.

MATLAB loop variable in COMSOL Special Operators

Please login with a confirmed email address before reporting spam

As shown in Figure (Attachment), ti is a loop variable and tti=ti^2 is assigned in timeint(t1,t2,expr,tol)----COMSOL Special Operators. Where t1 and t2 must be real scalars. However, this operation is wrong. tti=num2str(tii) is also wrong.

The following operation is right. where t1=1.
model.result.numerical('gev1').set('expr', 'timeint(1,t,intop1(K11(x,y)/mug*px+K12(x,y)/mug*py))');

Could you tell me how to solve this problem?

Thaks all

regards


1 Reply Last Post 28.10.2016, 08:42 GMT-4
Lars Gregersen COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 8 years ago 28.10.2016, 08:42 GMT-4
Hi Jia

I'm not really sure about what you are trying to do.

If you have a scalar variable tii in Matlab and you wish to transfer its value to Comsol such that Comsol can evaluate it as part of an expression the easist way is to set up a parameter in the Comsol model:

model.param.set('tii', tii);

You may need to solve again or call model.sol('sol1').updateSolution in order to get the value into the solution so you can use it for postprocessing.

There is also the possibility of adding the value to the const property of the EvalGlobal node 'gev1'.


If this does't work out for you then please send your model to support and we'll have a look.


--
Lars Gregersen
Comsol Denmark
Hi Jia I'm not really sure about what you are trying to do. If you have a scalar variable tii in Matlab and you wish to transfer its value to Comsol such that Comsol can evaluate it as part of an expression the easist way is to set up a parameter in the Comsol model: model.param.set('tii', tii); You may need to solve again or call model.sol('sol1').updateSolution in order to get the value into the solution so you can use it for postprocessing. There is also the possibility of adding the value to the const property of the EvalGlobal node 'gev1'. If this does't work out for you then please send your model to support and we'll have a look. -- 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.