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.
External matlab function -matlab Path and ElemStruct problems
Posted 1 déc. 2011, 03:04 UTC−5 Interfacing, LiveLink for MATLAB Version 4.2a 4 Replies
Please login with a confirmed email address before reporting spam
Hi everyone,
I’m building an external matlab function and following the guidance of the document. But the function fails to work. The matlab function is same as what the document ‘LiveLink For MATLAB Users' Guide’ (page 42) says:
function c=func1(x)
c=(x./1.6).*(x>0.6)+(x.^2+0.3).*(x<=0.6);
The .m file is save as ‘func1.m’ as the attachment shown. Then in COMSOL, I build/add a matlab node under the Global Definitions (Global Definitions – Functions –Matlab), then specify the function/argument, and finally the plot parameters. But, when I use “plot” to plot the function, it doesn’t work.
Fig. 1 Operating flow
(all the pictures and text are illustrated in the .doc file, thanks. )
Question one:
About the matlab and COMSOL path relative to the external matlab function
The matlab path:
Fig. 2 the path of matlab
(Ps. I didn’t set the path to “E:\papers\paper COMSOL”)
1. When I put the .m and .mph files to the “D:\COMSOL 4.2a\COMSOL42a”, then the error “failure loading matlab libraries, this model requires that matlab is available” appears.
Fig. 3 the loading error
2. When I put both files under the directory “E:\papers\paper COMSOL”
Fig. 4 the save path of both files
The error mentioned above disappears, while another error “internal error: cannot convert ElemStruct to int” comes,
Fig. 5 the ElemStruct error
The above phenomena puzzle me a lot, the matlab path can be change very easily and take effect immediately. Does during these change in matlab path, the COMSOL don’t responses correspondingly?
Question two:
How to solve the “internal error: cannot convert ElemStruct to int” problem
I have searched the forum and find Annika Rödder have encountered the same problem (see website www.comsol.com/community/forums/general/thread/23188/ for details). However, I haven’t understood the answer and underlying problem.
Could you give me some guidance?
Thanks for your response sincerely. Best wishes to you and your family.
FM Huang
Dec. 1st. 2011
I’m building an external matlab function and following the guidance of the document. But the function fails to work. The matlab function is same as what the document ‘LiveLink For MATLAB Users' Guide’ (page 42) says:
function c=func1(x)
c=(x./1.6).*(x>0.6)+(x.^2+0.3).*(x<=0.6);
The .m file is save as ‘func1.m’ as the attachment shown. Then in COMSOL, I build/add a matlab node under the Global Definitions (Global Definitions – Functions –Matlab), then specify the function/argument, and finally the plot parameters. But, when I use “plot” to plot the function, it doesn’t work.
Fig. 1 Operating flow
(all the pictures and text are illustrated in the .doc file, thanks. )
Question one:
About the matlab and COMSOL path relative to the external matlab function
The matlab path:
Fig. 2 the path of matlab
(Ps. I didn’t set the path to “E:\papers\paper COMSOL”)
1. When I put the .m and .mph files to the “D:\COMSOL 4.2a\COMSOL42a”, then the error “failure loading matlab libraries, this model requires that matlab is available” appears.
Fig. 3 the loading error
2. When I put both files under the directory “E:\papers\paper COMSOL”
Fig. 4 the save path of both files
The error mentioned above disappears, while another error “internal error: cannot convert ElemStruct to int” comes,
Fig. 5 the ElemStruct error
The above phenomena puzzle me a lot, the matlab path can be change very easily and take effect immediately. Does during these change in matlab path, the COMSOL don’t responses correspondingly?
Question two:
How to solve the “internal error: cannot convert ElemStruct to int” problem
I have searched the forum and find Annika Rödder have encountered the same problem (see website www.comsol.com/community/forums/general/thread/23188/ for details). However, I haven’t understood the answer and underlying problem.
Could you give me some guidance?
Thanks for your response sincerely. Best wishes to you and your family.
FM Huang
Dec. 1st. 2011
4 Replies Last Post 5 déc. 2011, 19:50 UTC−5