Quantcast
Channel: Latest Discussions - COMSOL Forums
Viewing all articles
Browse latest Browse all 2194

Trouble extracting a derived value into Matlab

$
0
0
Hello everyone!

As the title says I got some trouble getting numerical values from my derived values into matlab variables when using the livelink for matlab. What I do is I create a model in comsol, save it as an .m file, turn it into a function and use it in an optimization algorithm. Thus I need to get a comsol derived value into a matlab variable to close the loop.

What I get when I translate the model into an .m file is this:

model.result.numerical.create('av2', 'AvSurface');
model.result.numerical('av2').selection.all;
model.result.numerical('av2').selection.set([2]);
model.result.numerical('av2').set('expr', 'sqrt((mfnc.Br*d(mfnc.Br,r)+mfnc.Bphi*(1/r)*d(mfnc.Br,phi)+mfnc.Bz*d(mfnc.Br,z))^2+(mfnc.Br*d(mfnc.Bphi,r)+mfnc.Bphi*(1/r)*d(mfnc.Bphi,phi)+mfnc.Bz*d(mfnc.Bphi,z))^2+(mfnc.Br*d(mfnc.Bz,r)+mfnc.Bphi*(1/r)*d(mfnc.Bz,phi)+mfnc.Bz*d(mfnc.Bz,z))^2)');

What I want to do is get the value of 'av2' into a matlab variable. I tried using mpheval and mphglobal but it didnt work, not sure if I am using them right.Does anyone have any ideas?

Viewing all articles
Browse latest Browse all 2194

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>