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.

Plotting Random Geometry on Comsol Live link with Matlab.

Please login with a confirmed email address before reporting spam

I am working on Comsol Live Link for Matlab. I am trying to plot random circles in a certain range without overlapping. I am able to plot the circles however the circles will overlap and I can't find a solution for that. Please see the code below.

clc model = ModelUtil.create('Model2');

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

r=1;C1=2;C2=2;%matlab variables

model.param.set('r',r,'radius');

model.param.set('C1',C1,'coordinate of center');

model.param.set('C2',C2,'coordinate of center');

prompt= 'Enter the value N \n';

N=10;

for j=1:1:N

tag=model.geom('geom1').feature().uniquetag('crc');

model.geom('geom1').feature().create(tag,'Circle');

model.geom('geom1').feature(tag).set('r', r);

model.geom('geom1').run(tag);

r=r+(5-r).*rand(1,1)

end

for j=1:1:N

model.geom('geom1').feature(tag).set('pos', [C1 C2]);

C1=C1+(5-C1).*rand(1,1)+r

C2=(C2+(5-C1).*rand(1,1))+r

model.geom('geom1').run(tag);

end

model.label('Model2.mph');

mphgeom(model)


0 Replies Last Post 2018年1月31日 GMT-5 03:14
COMSOL Moderator

Hello Farjad Iqbal

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.