Quantcast
Channel: LabWindows/CVI topics
Viewing all articles
Browse latest Browse all 5362

CVI and Matlab Automation Server Issues

$
0
0

I am looking to use a the Matlab Automation sever to run a few Matlab functions that cannot be run outside of the Matlab environment from within my CVI project.  I am using Matlab 2012b and CVI2013.  Right now I created a very simple CVI project to test out functionality before throwing it into my more complicated project.

 

I seem to havve no problem lauching the Matlab command prempt and I can manually type in functions and execute them just as though I were had all of Matlab itself open.  After this I have two problems:

 

1) When I use MLApp_DIMLAppExecute it does not seem to work for to run a script.  I give the following Matlab command:

run('<path>\<script.m>');

 

Now if I type that same command into the comand prompt that CVI opened, it works just fine.  Also I have tried doing something like "d = 2;" for the command and then if I type "d" into the command prompt it will return "2" so I'm not sure what is happening there.

 

2) When I use MLApp_DIMLAppQuit, it closes the command prompt but does not kill the Matlab process and so if I use MLApp_NewDIMLApp again it doesn't actually create anything new and a command prompt never pops up.

 

Below I have included my source code for my simple example that I've been playing with.

 

#include "matlabsrv2012b.h"
#include "main.h"

static CAObjHandle hdlMatlab = 0; int main (int argc, char *argv[]){ HRESULT hStatus = 0; char* returnValue = NULL; hStatus = MLApp_NewDIMLApp(NULL,1,LOCALE_NEUTRAL,0,&hdlMatlab); hStatus = MLApp_DIMLAppExecute(hdlMatlab,NULL,"run('C:\CoreEH\Tools\EH_Common_Workspace_Channel_Generator\Matlab_Fcns\main.m');",&returnValue); hStatus = MLApp_DIMLAppQuit(hdlMatlab,NULL); return 0; }

 

Any input on what might be causing these problems would be great.  Thanks in advance.


Viewing all articles
Browse latest Browse all 5362

Trending Articles



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