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.

Comsol with Matlab

Please login with a confirmed email address before reporting spam


Hi,

I have a problem in linking a model on Comsol with some m-files in Matlab. I have made a model in Comsol and save it as mfile. I have also defined some points (PT1, PT2, ....) on the boundaries. Now, I would like to evaluate electric potential at these points and use them as a imput for other mfiles.
I do not know how I can use the electric potential at some specific points as outputs of my comsol model. How can I define following statement in the mfile of my comsol model:

[Voltage at PT1, Voltage at PT2, Voltage at PT3, .....]=comsol-model(PT1,PT2,PT3,....)


thank you in advance,
Saeid

3 Replies Last Post 9 mag 2011, 03:06 GMT-4

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 3 mag 2011, 09:07 GMT-4
Hi Saeid,

Try looking in the COMSOL LiveLink™ for MATLAB® User's Guide at the following commands to see if they do what you want:
1. mpheval
2. mphinterp

The first one pulls results at specified node points, the second one pulls results at arbitrary points.

This is the code I use for extracting the electric field at specified coordinates:

fieldMap(:,1:3) = coordinates;
[fieldMap(:,4),fieldMap(:,5),fieldMap(:,6)] = mphinterp(model, {'es.Ex','es.Ey','es.Ez'}, 'coord', coordinates.');

This comes from a function with is available on launchpad at bazaar.launchpad.net/~mattachu/modelrfq/trunk/view/head:/Matlab/ComsolInterface/getFieldMap.m

Hope it helps!
matt
Hi Saeid, Try looking in the COMSOL LiveLink™ for MATLAB® User's Guide at the following commands to see if they do what you want: 1. mpheval 2. mphinterp The first one pulls results at specified node points, the second one pulls results at arbitrary points. This is the code I use for extracting the electric field at specified coordinates: fieldMap(:,1:3) = coordinates; [fieldMap(:,4),fieldMap(:,5),fieldMap(:,6)] = mphinterp(model, {'es.Ex','es.Ey','es.Ez'}, 'coord', coordinates.'); This comes from a function with is available on launchpad at http://bazaar.launchpad.net/~mattachu/modelrfq/trunk/view/head:/Matlab/ComsolInterface/getFieldMap.m Hope it helps! matt

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 8 mag 2011, 03:25 GMT-4
Hi mattachu,

Thanks for you reply.

I use Comsol 3.5a and Matlab 2008. I can connect this two programs, but when I save my model in .m format and run it in Matlab, I have not obtained any results!!!
I am not sure that if it is because of Comsol and Matlab programs or I have any other problems in my modeling?! I have attached my mfile to this message, Would you please check it?!

Input and outputs of this mfile should be 40*1 vectors.

Thanks,
Saeid
Hi mattachu, Thanks for you reply. I use Comsol 3.5a and Matlab 2008. I can connect this two programs, but when I save my model in .m format and run it in Matlab, I have not obtained any results!!! I am not sure that if it is because of Comsol and Matlab programs or I have any other problems in my modeling?! I have attached my mfile to this message, Would you please check it?! Input and outputs of this mfile should be 40*1 vectors. Thanks, Saeid


Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 9 mag 2011, 03:06 GMT-4

I use Comsol 3.5a and Matlab 2008.


Ah, I'm sorry then, I only have experience with extracting data from Comsol 4. Unfortunately the functions I mentioned above are only available in later versions of Comsol. When I used to use Comsol 3.5a I just extracted data manually rather than using Matlab.

Hopefully someone else will have the knowledge to help you.
[QUOTE] I use Comsol 3.5a and Matlab 2008. [/QUOTE] Ah, I'm sorry then, I only have experience with extracting data from Comsol 4. Unfortunately the functions I mentioned above are only available in later versions of Comsol. When I used to use Comsol 3.5a I just extracted data manually rather than using Matlab. Hopefully someone else will have the knowledge to help you.

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.