Plotting Random Geometry on Comsol Live link with Matlab.

7 ビュー (過去 30 日間)
Iqbal Farjad
Iqbal Farjad 2018 年 1 月 31 日
コメント済み: Charles Dorchester 2020 年 11 月 4 日
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;C3=1; %matlab variables
model.param.set('r',r,'radius');
model.param.set('C1',C1,'coordinate of center');
model.param.set('C2',C2,'coordinate of center');
%model.param.set('C3',C3,'coordinate of center');
prompt= 'Enter the value N \n';
N=10; %input(prompt);%This may vary based on user input
for j=1:1:N
tag=model.geom('geom1').feature().uniquetag('sph');
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)
  1 件のコメント
Charles Dorchester
Charles Dorchester 2020 年 11 月 4 日
Hi Iqbal,
I'm curious if you ever found a solution to this? I am currently searching through forums on how to do this exact process.

サインインしてコメントする。

回答 (1 件)

Trung Hoang Dinh
Trung Hoang Dinh 2020 年 1 月 11 日
Dear Mr. Iqbal
I am also usinh Matlab to generate geometry for COMSOL. However, when I export the mph file, it is empty. That means the code I downloaded from inter it is not linked to the model. Could you let me know how you linked your code to model?
Thank you very much.

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by