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.

MATLAB LiveLink

Please login with a confirmed email address before reporting spam

Hey there,

I am using LiveLink MATLAB but when running my model, the notice "Undefined function or variable 'mphopen'" is emerged on the command window. However, I have set up the file "domain_activation_llmatlab" in the MATLAB path. could it be some problem related to LiveLinke? How could I find it that my COMSOL 5.2a can LiveLink to the MATLAM R2016a.
this is one of the comsol's sample problems (www.comsol.com/model/domain-activation-and-deactivation-12060). I, however, cannot do this. what do you suggest. the MATLAB code is as follows:
------------------
model = mphopen('domain_activation_llmatlab');
domInd = [2,3,5,4];
ht = model.physics('ht');
for i = 1:8
k = mod(i,4);
if k == 0
k = 4;
end
ht.selection.set([1 domInd(k)]);
ht.feature('init2').selection.set(domInd(k));
model.study('std1').run;
if i==1
cpt1 = model.result.dataset.create('cpt1', 'CutPoint3D');
cpt1.set('pointx', '0 L/2 L');
cpt1.set('pointy', '0 L/2 L');
cpt1.set('pointz', 'L/10');
pg1 = model.result.create('pg1', 'PlotGroup1D');
pg1.set('data', 'cpt1');
ptgr1 = pg1.feature.create('ptgr1', 'PointGraph');
ptgr1.set('legend', 'on');
pg2 = model.result.create('pg2', 'PlotGroup3D');
surf1 = pg2.feature.create('surf1', 'Surface');
surf1.set('rangecoloractive', 'on');
surf1.set('rangecolormax', '336');
surf1.set('rangecolormin', '293.15');
ht.feature('init1').set('T', 1, 'T');
v1 = model.sol('sol1').feature('v1');
v1.set('initsol', 'sol1');
end
figure(1)
mphplot(model,'pg1','rangenum',1)
hold on
figure(2)
subplot(4,2,i)
pg2.setIndex('looplevel','25',0);
mphplot(model,'pg2');
time = mphglobal(model,'t','solnum','end');
model.param.set('t0',time);
disp(sprintf('End of iteration No.%d',i));
end
----------------------

1 Reply Last Post 12.01.2017, 09:12 GMT-5
Lars Gregersen COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 8 years ago 12.01.2017, 09:12 GMT-5
Hi

Make sure you start "Matlab with Comsol" before running any scripts in Matlab that use Comsol

See the manual Introduction to LiveLink for Matlab in the chapter called Starting COMSOL with MATLAB.

--
Lars Gregersen
Comsol Denmark
Hi Make sure you start "Matlab with Comsol" before running any scripts in Matlab that use Comsol See the manual Introduction to LiveLink for Matlab in the chapter called Starting COMSOL with MATLAB. -- Lars Gregersen Comsol Denmark

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.