- #1
luhao
- 1
- 0
Hi I'm a new user in Comsol and Matlab and I have to create boxes within a box. Of course those boxes are easy, my problem is how do you make loops in MATLAB that translates to the g1=rect2(blah blah)
g2=rect2(blah blah)..
For example:
The boxes within the outside box varies so it's better to write everything in a loop say 5 boxes
and i had
length=[1,2,3,4,5];
width=[1, 1, 1, 1, 1];
cornerx=[0, 5, 10, 15, 20];
num=5;
for i=1:num;
name=strcat('g',num2str(i));
name=rect2(width(i),length(i),'base','corner','pos',[cornerx,0])
end;
Of course that would not work because the variable name will be overwritten everytime the rect2 occurs. Comsol doesn't follow that name=rect2(width(i),length(i),'base','corner','pos',[cornerx,0]), since it only recognizes g1= , g2=, etc.
Is there any way to write the loop and COMSOL would understand that i want to write 5 or 6 or 7 boxes in a box other than writing out each g1 g2 g3 manually?
Thanks!
Luhao
g2=rect2(blah blah)..
For example:
The boxes within the outside box varies so it's better to write everything in a loop say 5 boxes
and i had
length=[1,2,3,4,5];
width=[1, 1, 1, 1, 1];
cornerx=[0, 5, 10, 15, 20];
num=5;
for i=1:num;
name=strcat('g',num2str(i));
name=rect2(width(i),length(i),'base','corner','pos',[cornerx,0])
end;
Of course that would not work because the variable name will be overwritten everytime the rect2 occurs. Comsol doesn't follow that name=rect2(width(i),length(i),'base','corner','pos',[cornerx,0]), since it only recognizes g1= , g2=, etc.
Is there any way to write the loop and COMSOL would understand that i want to write 5 or 6 or 7 boxes in a box other than writing out each g1 g2 g3 manually?
Thanks!
Luhao