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.

Creating a custom matrix in COMSOL or MATLAB

Please login with a confirmed email address before reporting spam

Hi,

I am using V4.2 and I have defined several variables in COMSOL's Variable list in order to be used as the components of a matrix. The variables are a11,a12,...a34,a44 (please see the attached mph file).

I would like to create a matrix from these components and do some matrix operation later. So I created an m file from my mph file and exported it to MATLAB. In MATLAB using regular notations for creating matrix did not help; i.e.

A=[ a11 a12...;
... ..........;

... a34 a44]

failed perhaps because in the m file the variables have been defined as:
model.variable('var1').set('a11', 'cos(alpha) / cos(phi)');
model.variable('var1').set('a12', 'cos(alpha) / sin(phi)');
.....

I have also noticed that some variables, parameters and functions are handled like:

model.func.create()
model.param.set()
model.variable('var1).set()

But I could not find any section explicitly talking about those definitions, other than some scattered explanations. I am guessing that similar commands should be used in order to define the matrix.

Does anyone know how I can create the above matrix?
Is there any section in the documentation that describes these things?
Is there any way that a custom matrix can be made in COMSOL?

Thanks,

0 Replies Last Post 11 ago 2011, 15:30 GMT-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.