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.

Create arbitrary distribution of circles via Livelink for Matlab

Please login with a confirmed email address before reporting spam

Hallo Comsol Community

First of all, since i am very new to this discussion forum please excuse any 'unclearness' in the way i will try to express my problem.

I am currently using the matlab livelink feature of comsol 4.1 for creating a 2D geometry that consists of arbitrarily posistioned circles.

The way i am trying to do this is by the following matlab script:

model = ModelUtil.create('Model');
geom1 = model.geom.create('geom1',2);

index=1

x=randi([-100 100],30,1)
y=randi([-100 100],30,1)

index
for i=1:1:size(x,1)
c(i)= geom2.feature.create((strcat('c',i)),'Circle');
c(i).set('r',1);
c(i).set('pos',[x(i) y(i)]);
geom2.run;
index=index+1
end

geom2.run;

mphgeom(model,'geom2');


1) I really do not understand why each geometric element has to be under a different variable name.Right now i am incorporating all my circles inside the matrix called c and i do not know if this is correct.

2) If i run the same script with

x=randi([-100 100],40,1)
y=randi([-100 100],40,1) instead of


x=randi([-100 100],30,1)
y=randi([-100 100],30,1)


then i get an error on the geom2.run function that i also cannot explain.


1 Reply Last Post 15 mai 2012, 19:28 UTC−4
COMSOL Moderator

Hello Orestis Vardoulis

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.


Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 15 mai 2012, 19:28 UTC−4
I have a similar issue. I was able to make this into an array in 3.5a but in 4.2 I have not figured out a way to get around this naming issue.
I have a similar issue. I was able to make this into an array in 3.5a but in 4.2 I have not figured out a way to get around this naming issue.

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.