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.

How to put COMSOL and MATLAB in a for loop?

Please login with a confirmed email address before reporting spam

Hello, I have three questions about working with MATALB, COMSOL server, and COMOSL software. First, if I want to connect to COMSOL server, I use mphstart(<portnumber>). However, for that I have to open the COMSOL server, and then I can use the mentioned command. I want to know is there any other more convenient way to connect to the COMSOL server ?In other words when I open "COMSOL Multiphysics 5.3 with MATLAB" it automaticlly opens the MATLAB program which is connected to the COMSOL server. So, I don't understand the application of the metioned command.

Secondly, I have used MATLAB to create my geometry structure. The structure is a randomized distribution of NPs. Every time I run the M-file it gives a new structure. Then I run the COMSOL to analyze the system. I just want to know is it possible to put "for loop" for this purpose? I want to analyze more than 1000 structures. This can reduce dramatically the time I spend on my simulation. Because it has become a very boring thing to open the M-file and run the M-file, then open the COMSOL to run the simulation, then close the M-file to save the result and then again opening the M-file for simulating a new structure.

Finally, for creating a geometry object such as rectangular a command like this:

r2 = wp1.geom.feature.create('r2', 'Rectangle');

**Now if I want to write a command for clearing the created object what should I use? ** Thank you very much.


0 Replies Last Post Sep 29, 2017, 10:58 a.m. EDT
COMSOL Moderator

Hello Mohammad Rashidi

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.