LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can MatLab Script run in multi-cores?

Solved!
Go to solution

Whe LabVIEW runs a Matlab code through 'Matlab Script', does the 'Matlab Script' part run in a single-thread mode or multi-thread mode? It uses the ActiveX to communicate with Matlab so I am assuming it is single-thread?

 

I have a LabVIEW code which has to call a .m file. I am wondering whether the program performance will be greatly improved if I convert the .m file into a .dll to eliminate the need to activate the Matlab server very time. 

0 Kudos
Message 1 of 4
(3,351 Views)
Solution
Accepted by topic author MengHuiHanTang

You are correct in your supposition that the MATLAB Script nodes run single-threaded. Only one script will be able to run at a time.

 

You may be able to improve performance by building it into a DLL, but you'd have to test it on your machine to know by how much. I don't really thing this would be too significant. Building a code into separate DLLs may also allow you to improve performance by allowing for parallelization as you could call the separate DLLs in different threads, I believe.

 

Another option would be using the MathScript node - that allows for parallelization.

 

MATLAB® is a registered trademark of The MathWorks, Inc.

0 Kudos
Message 2 of 4
(3,330 Views)

Thanks for the reply. That confirmed my thought that my Matlab Script is running as the single thread.

 

I wanted to confirm this because I was sure that the program was not using the multicores and HT technology on the CPUs. By converting to a DLL and allowing parallization, it can run all the eight CPU cores which I am sure will improve its performance.

 

The other option you mentioned is MathScript. I am not familiar with it. Can it also run matlab code? and allows parallization? What the difference from Matlab Script.

 

Thanks again. 

0 Kudos
Message 3 of 4
(3,303 Views)

The MathScript RT Module allows you to run your .m files within the LabVIEW environment so that it's all LabVIEW under the hood. It does not call into the MATLAB engine like the MATLAB script node does. 

 

MATLAB® is a registered trademark of The MathWorks, Inc.

0 Kudos
Message 4 of 4
(3,294 Views)