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.

how to assign a value to the application varaibles in matlab script?

Please login with a confirmed email address before reporting spam

Hi, guys,
I bulit a RF modle with the wavelength as physical variable. Now I save it as a M-file in matlab. The problem is how can I assign a value to the wavelength?

I wrote it as following (main part), but it did not work.

-----------------------

a = 0.5;

% Application mode 1
clear appl
appl.mode.class = 'InPlaneWaves';
appl.name = 'rfweh';
appl.module = 'RF';
appl.sshape = 2;
appl.assignsuffix = '_rfweh';
clear prop
prop.field='TES';
prop.inputvar='lambda';
appl.prop = prop;
clear bnd
bnd.type = {'SC','cont'};
bnd.ind = [1,1,1,2,1,2,1,2,1,2,2,2,2,1,2,1,2,2,2,2,1,1,1,1,2,2,2,2,2,2, ...
2,2];
appl.bnd = bnd;
clear equ
equ.coordOn = {{1;1},{1;0},{0;1},{0;0},{0;0}};
equ.epsilonr = {1,1,1,1,3};
equ.Stype = {'coord','coord','coord','none','none'};
equ.ind = [1,2,1,3,4,3,1,2,1,5];
appl.equ = equ;
appl.var = {'lambda0','a'};
fem.appl{1} = appl;
fem.frame = {'ref'};
fem.border = 1;
clear units;
units.basesystem = 'SI';
fem.units = units;

---------------------------

But if I change the 'a' to '0.5' in the line appl.var = {'lambda0','a'};, it works.

How can I assign a self-defined variable to the wavelength and bulit a loop using the script language?

Thanks in advance!

1 Reply Last Post Jan 28, 2011, 11:38 a.m. EST

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Jan 28, 2011, 11:38 a.m. EST
You can substitue 'a' with num2str(lambdaVector(loop))
You can substitue 'a' with num2str(lambdaVector(loop))

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.