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.

converting geometry from MATLAB to Livelink to MATLAB and COMSOL

Please login with a confirmed email address before reporting spam

My concern is to import a geometry which was originally built in MATLAB into COMSOL. For this I am using Livelink to MATLAB.
I made a MATLAB program which is plotting circles of same radius at different centre points. The centre points are placed to circles using for loops. (The schematic of pattern is attached in the file)
Now I want to convert this MATLAB code to Livelink to MATLAB format so that I can open the same geometry in COMSOL. My requirement follows approx same methodology which is given at page number 40-41 manual of Livelink to MATLAB user guide to plot circles at different centre points. The methodology says that the first circle plotted with given position and when then the loop rewind, the new values of centre point is allocated and the new circle will be plotted. The first circle remain on its position (Unfortunately I am unable to execute it)
Infact what happens is that when I write the following:
Note: Xcoord(x,y) and Ycord(x,y) represent a matrix of required x,y co-ordinates of n circles.
for y=1:ny
for x=1:nx
c1=model.geom('geom2').feature.create('c1','Circle');
c1.set('r',rad);
c1.set('pos',[Xcoord(x,y) Ycoord(x,y)]);
model.geom('geom2').run;
hold on
end
end
mphgeom(model,'geom2');

Then following error appears:
An object with the given name already exists
- Name: c1
It means that c1 is defined as one circle. However when the loop rewind, it re-assigns the new value of center position of the same circle ‘c1’ which is not accepted and program terminated. The first circle c1 is individual circle so the second circle must be c2 and not c1. My concern is that how I can write a code such that the first circle remains undisturbed and when the loop rewind, the new circle will be ploted. This will continue until the required number of circles will be plotted.



0 Replies Last Post 2011年1月26日 GMT-5 22:01
COMSOL Moderator

Hello Zeeshan Mohiuddin

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.