LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling MatLab from Labivew

I'm trying to call a MatLab.m program from Labview to analyze some data. I think I can use System Exec.vi to do this? If so how do I specify the file path? I'm not too sure how to use the sub VI. Smiley Sad

I tried specify the file input (ie C:\math.m) but nothing seemed to happen.

I'm using Labview 6.1 and MatLab 7.

Message Edited by Honeywell on 07-05-2005 12:06 PM

0 Kudos
Message 1 of 8
(3,925 Views)
Help anyone? Smiley Sad
0 Kudos
Message 2 of 8
(3,916 Views)
Hello Honeywell,

There is Matlab Script node in Labview located at All Functions -> Analyze -> Mathematics -> Formula.
It is similar to the LabVIEW formula node, but it allows you to import an existing MATLAB script and run the script from LabVIEW. As with a formula node, you may pass data to and from the node (i.e., pass data from LabVIEW to your Matlab script and get the output back in LabVIEW). LabVIEW uses ActiveX to pass the script to MATLAB for execution.

As for the System.exec.vi, it lets you execute system commands, and you would specify the command line for it as if you would for windows command prompt.

Hope this helps and let me know if you have more questions about this.
Good luck and have a great day!
Shakhina P.
Applications Engineer
National Instruments
0 Kudos
Message 3 of 8
(3,903 Views)
Hi Thanx for the reply.

I don't think the MatLab Script node is going to work though. The MatLab script/program I'm planning to use basically takes some inputs from Labview, calculates some stuff, then the user can enter some commands to get some mathematical results. Or would MatLab Script node work in this case?

So for the System.exec.vi the only input I need would be program's location? (ie C:\MatLab\analysis.m)


0 Kudos
Message 4 of 8
(3,900 Views)
Hi Honeywell,

As long as the input to and output from the matlab script is numerical data of one those types:
    Real, Complex, Real Vector, Complex Vector, Real Matrix, Complex Matrix, String, Path
then you should be fine using the Matlab Script node.

Regarding your other question, it seems like Matlab command line options for executing a .m file is:
    path_to_Matlab_folder\bin\win32\matlab.exe /r myScript
where you have myScript.m in the default working directory of Matlab.

So in System exec.vi for command line you can enter just that.

Good luck!
Shakhina P.
Applications Engineer
National Instruments

0 Kudos
Message 5 of 8
(3,879 Views)
Hi Thanx for the reply.

I understand it's possible to compile the matlab script into a dll and use Call Library Function Node to use the script. Do you know how I can do that?

Which way would be easier? (Use MatLab node vs Library).


0 Kudos
Message 6 of 8
(3,875 Views)

If you need to execute the Matlab script without invoking Matlab, then you can create a DLL and call it in LabVIEW using the Call Library Function Node. However, if it is Ok to invoke Matlab, then you can simply use the Matlab Script node, since it is a lot easier to use.

If you choose to go with the DLL route, you might be interested in this discussion forum post about creating a Matlab DLL and calling it in LabVIEW: dll, matlab an LadVIEW.

Good luck and best regards,
Shakhina P.
Applications Engineer
National Instruments
0 Kudos
Message 7 of 8
(3,847 Views)
So if I use the MatLab script MatLab will need to be installed on the computer and it will be executed when the script is run?

If I go with dll that's not true is that correct?

Message Edited by Honeywell on 07-11-2005 11:13 AM

0 Kudos
Message 8 of 8
(3,846 Views)