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.

RF Modal Analyisis + Livelink: ploting other modes.

Please login with a confirmed email address before reporting spam

Hi to all,

as I've seen in the Livelink for Matlab introduction tutorial, a good way to learn to use Livelink is by saving the comsol file as an .m file and then opening it on the Matlab editor.

So far so good the file ran and finished without any error message. After that, on the Matlab's Command Window I'd executed:

>> mphplot(ans,'pg1')

and I get a beautiful plot of the last mode I'd calculated for the last parameter (parameter sweep for parameter 'M').

Unfortunately, I haven't been able to find a way to plot other modes for the same M (or for another value of M).

At the end of this message I'm including the last lines of my .m file, which I believe are necessary for you to know how I'm storing the solutions.

Cheers,
--
Felipe


(...)

model.sol('sol1').feature('st1').name('Compile Equations: Mode Analysis');
model.sol('sol1').feature('st1').set('studystep', 'mode');
model.sol('sol1').feature('v1').set('control', 'mode');
model.sol('sol1').feature('e1').set('control', 'mode');
model.sol('sol1').feature('e1').set('transform', 'effective_mode_index');
model.sol('sol1').feature('e1').set('shift', 'chute');
model.sol('sol1').feature('e1').feature('aDef').set('complexfun', true);
model.sol('sol1').runAll;

model.batch('p1').set('control', 'param');
model.batch('p1').set('pname', {'M'});
model.batch('p1').set('plist', '{1,0.8}');
model.batch('p1').set('err', true);
model.batch('p1').feature('so1').set('seq', 'sol1');
model.batch('p1').feature('so1').set('psol', 'sol2');
model.batch('p1').feature('so1').set('param', {'"M","1"' '"M","0.8"'});
model.batch('p1').attach('std5');
model.batch('p1').run;

model.result('pg1').name('Electric Field (emw)');
model.result('pg1').set('data', 'dset2');
model.result('pg1').set('solnum', '5');
model.result('pg1').set('outersolnum', '1');
model.result('pg1').feature('surf1').set('unit', '');

out = model;

1 Reply Last Post 16 févr. 2012, 08:26 UTC−5

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 16 févr. 2012, 08:26 UTC−5
Finally I found my way.

So I will answer myself here for future references:

Suppose you have your results stored under the variable 'model' with 6 eigenvalues, then, in order to change to the fifth eigenvalue (for example) you write in the matlab command window:

model.result('pg1').set('solnum', '5');

where pg1 is the comsol's tag you used to store the results at the end of your matlab script.

Now you can plot it:

mphplot(model,'pg1')

or print the results (i.e. the effective refractive index):

mphglobal(model,'emw.neff')

enjoy!
--
Felipe
Finally I found my way. So I will answer myself here for future references: Suppose you have your results stored under the variable 'model' with 6 eigenvalues, then, in order to change to the fifth eigenvalue (for example) you write in the matlab command window: model.result('pg1').set('solnum', '5'); where pg1 is the comsol's tag you used to store the results at the end of your matlab script. Now you can plot it: mphplot(model,'pg1') or print the results (i.e. the effective refractive index): mphglobal(model,'emw.neff') enjoy! -- Felipe

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.