Note: This discussion is about an older version of the COMSOL Multiphysics® software. The information provided may be out of date.

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.

Forming a matrix in MATLAB from custom-defined variables of COMSOL

Please login with a confirmed email address before reporting spam

Hi,

In my model I have created some variables in Variables list of COMSOL. Then I saved my mph file as an m file and opened it in MATLAB. My variables a11, a12, a21 and a22 that were created in COMSOL will have the form below after importing them in MATLAB:

model.variable('var1').set('a11', 'cos(alpha) / cos(phi)');
model.variable('var1').set('a12', 'cos(alpha) / sin(phi)');
model.variable('var1').set('a13', 'sin(alpha) / cos(phi)');
model.variable('var1').set('a14', 'sin(alpha) / sin(phi)');

I tried the common way of forming matrix (see below), but it gives an error saying that the a's are not defined:

A=[ a11 a12 ; a21 a22]

Does anyone know how this can be done?

Thanks,
Jessica

0 Replies Last Post 9 août 2011, 17:56 UTC−4
COMSOL Moderator

Hello Jessica

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.

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.