LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Execute m-file without starting Matlab

Hello,

I would like to execute a Matlab m-file several times from LabView.
I want to start Matlab only once at the beginning and then leave it opened.
If I use the SystemExecution.vi, I can use the system instruction to execute the script, but this also starts Matlab.
I don't think that using Math Script Node is a good idea, since the Matlab code is huge and consists of lots of m-files, therefore I don't want to paste the whole code into the Script Node.

How can I do this?

Regards,

Gerald

0 Kudos
Message 1 of 4
(5,973 Views)
You may exploit the Matlab ActiveX server interface, see External Interfaces in http://www.mathworks.com/access/helpdesk/help/techdoc/index.html
Doesn't seem to be very immediate, though, unless you are skilled in COM/ActiveX
Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 2 of 4
(5,965 Views)
Hi Gerald,
 
Some alternatives to consider:
  • You could try invoking your .m file script from MathScript by calling it from the MathScript node rather than inserting the entire script. To do so, you would save your script(s) in a folder that's part of the MathScript search path. (See the help for the path command (here) for more info about this search path.)
  • LabVIEW includes a "MATLAB Script Node" that allows you to call on an installed copy of The Math Works Inc. MATLAB® software to execute your m file scripts. This node coexists with LabVIEW graphical code as a "script node," a rectangular region that you can add to your LabVIEW block diagrams and use to enter or load .m files. When the node executes, LabVIEW calls the MATLAB software to execute the .m file script. See this link for more information about the Matlab script node.
 
Hope this helps...
 
--Sam
 
 
MATLAB® is a registered trademark of The MathWorks, Inc.
Sam Shearman
0 Kudos
Message 3 of 4
(5,957 Views)
Hello,

thanks for your help, but unfortunately it does not work.
The Math Script Node does not accept the syntax of my m-file (I know it is correct). I only imported the main m-file that calls all other modules. I dont't know if this is enough?
When I import the m-file into the Matlab  Script  Node nothing happens when I execute the VI, not even an error. I tried to run one of the examples that are listed in the help, this generates an error: Error during transfer of the variable to the script server.
I am using LabView 8.2 and Matlab R2006b.
Why is this so complicated to run a code from another program?
Is there another way to run Matlab-code?

Regards,

Gerald



0 Kudos
Message 4 of 4
(5,949 Views)