01-24-2007 10:09 AM
01-24-2007 10:54 AM
Hi,
Sorry it took me so long to reply - I gave birth
About the MCR - the Mathworks specifically forbid posting it on the web (I don't know why) and it's 85 Mb so I can't send it by mail. Maybe you can get it from another source (if you still want it at all).
About the example wrapper file - it's there in the zip. It is the c++ files.
There is also a good example in the mathworks: http://www.mathworks.com/support/solutions/data/1-PM4OX.html?1-PM4OX that gives an example of loading a matlab dll file in MSVC 6. To create a dll all you have to do is choose dll instead of exe in your MSVC project.
Hope this helps,
Danielle
01-24-2007 11:04 AM
01-24-2007 11:27 AM
hi,
Danielle, congratulations on your new baby! As a coincidence, I myself just am back at work from giving birth too
The extensive LabView code the module using the Matlab-generated DLL will be integrated in, is not easily transferred to a LabView version beyond 7.0. Also we don't want to install Matlab on every computer running the programm. So I am eager to solve the problem that the code only runs once and then crashes LabView.
Danielle, did you succeed in using the code provided by gnilsson?
Thanks for sharing your experiences!
Gudrun
01-25-2007 07:08 AM
Hi,
No, I didn't succeed in using the code of gnilsson. It didn't compile. I solved the problem by splitting the function into init, func and terminate. the init runs when the program starts; func is activated when user wants it; terminate runs when user presses quit. This allows the user to use the function more than once.
Good luck!
05-05-2007 08:00 PM
03-18-2008 04:45 PM
LLCVICALC_API
int CVIMatlabInit(void){
if(!mclInitializeApplication(NULL,0)){
//std::cerr << "Could not initialize MCR" << std::endl; return -5;}
if (!cviDLLInitialize()){ //fprintf(stderr,"Could not initialize the library.\n"); return -6;}
return 0;}
DLLCVICALC_API
int CVIMatlabTerminate(void){
bool bReturn = false;cviDLLTerminate();
cviDLLTerminate();
bReturn = mclTerminateApplication();
if ( bReturn == true ) return 0; else return -7;}
DLLCVICALC_API
int VIlineWidth(void){ int len = 0;mxLogical tf[1] = {
true};mxChar filetoprocess[13]={
's','a','m','p','l','e','A','.','t','i','f','f','\0'};mwArray mwMatlabOutput;
try { //len = strlen(in1);mwArray inMatlabData(1, 13, mxCHAR_CLASS);
inMatlabData.SetCharData(filetoprocess, 13);
//output arraymwArray inpFlag(1,1,mxLOGICAL_CLASS);
inpFlag.SetLogicalData(tf,1);
cviDLL(1,mwMatlabOutput,inMatlabData,inpFlag);
}
catch (const mwException & e) { return -3;}
catch(...) { return -4;}
return 0;}
03-18-2008 04:45 PM
LLCVICALC_API
int CVIMatlabInit(void){
if(!mclInitializeApplication(NULL,0)){
//std::cerr << "Could not initialize MCR" << std::endl; return -5;}
if (!cviDLLInitialize()){ //fprintf(stderr,"Could not initialize the library.\n"); return -6;}
return 0;}
DLLCVICALC_API
int CVIMatlabTerminate(void){
bool bReturn = false;cviDLLTerminate();
cviDLLTerminate();
bReturn = mclTerminateApplication();
if ( bReturn == true ) return 0; else return -7;}
DLLCVICALC_API
int VIlineWidth(void){ int len = 0;mxLogical tf[1] = {
true};mxChar filetoprocess[13]={
's','a','m','p','l','e','A','.','t','i','f','f','\0'};mwArray mwMatlabOutput;
try { //len = strlen(in1);mwArray inMatlabData(1, 13, mxCHAR_CLASS);
inMatlabData.SetCharData(filetoprocess, 13);
//output arraymwArray inpFlag(1,1,mxLOGICAL_CLASS);
inpFlag.SetLogicalData(tf,1);
cviDLL(1,mwMatlabOutput,inMatlabData,inpFlag);
}
catch (const mwException & e) { return -3;}
catch(...) { return -4;}
return 0;}
03-18-2008 04:55 PM
Attached is a code
John
07-29-2008 01:57 PM