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 functions

Please login with a confirmed email address before reporting spam

Hi there,

Does anyone know how to write MATLAB functions for a 2D problem from within COMSOL? I can call MATLAB functions from COMSOL when both programs are connected together and when dealing with a 1D problem only using options>functions>analytic etc...

In 1D COMSOL passes (1,n) arrays to MATLAB for use in the function where (n) is the number of mesh points and the array value can be made of independent or solution variables. In 2D COMSOL passes a (1,n) array whose length is the total sum of nodes along the boundaries and to my knowledge its values are those of the solution variable, or any other variable for that matter but embeded in this weird looking array.

Is there away of reshaping this array to an interpolated (m,n) matrix of the variable? I'm after calling functions from withing COMSOL rather than migrating the whole code to MATLAB as its over 300000 of repeated lines!

I'm open for other suggestions too :)

Your help would be much appreciated,
Laith


0 Replies Last Post May 24, 2010, 4:22 a.m. EDT
COMSOL Moderator

Hello Laith Hurmez

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.