Showing results for 
Search instead for 
Did you mean: 

Why are mathscript performances much below matlab's?

Go to solution

Dear all,


I'm doing signal processing on a signal acquired with a ADC. The flow on information is roughly a 10 000x1000 int8 matrix per second. I'm trying to process the data at the same speed. Signal processing is done in a .m matlab file. The processing is much to complicated to be coded in G code.


I have two choices:

1. use matlab nodes

2. use Mathscript nodes.


I implemented solution 1 but loses a lot of time just for data transfert between labview and matlab (transfer of ~10MB matrix). Then Matlab is very fast at doing the signal processing. A faster version of this solution was to write the matrix in a bin file and pass the filename to matlab. It is faster (don't ask me why) but still isn't fast enough.


Solution 2 sounds better because as Mathscript is a native language, there is no need for transfer. Before switching to Mathscipt, I did the following test: execute the same simple code on both solutions: compute the fft of a 1024x1024 matrix ten times (attached code).


Result is that Matlab node version takes 0.5s versus 1.6s for Mathscript node version.


Why is the performance of mathscript so much below the performance of the matlab node?


If indeed Mathscript is much slower than Matlab, then I fear I'll stick with matlab node. Is there any better way to transfer data than through files?


Thanks in advance for your replies!





0 Kudos
Message 1 of 4
Accepted by topic author clapiotte

Not sure I can help you, but I have found the same thing.


I can have a few guesses - are you using 64bit Matlab? if so you may have noticed that MathScript only works in 32bit LabVIEW.


The other possibility is that Mathscript runs as an embedded process within LabVIEW whereas if you're using MatLab you use Simulink to communicate with Matlab in its own thread.

Third option could simply be that Matlab is a far more optimised commerical product.


Honest answer is that I don't know!

David Clark
IDEX Biometrics UK Ltd
Hampshire, England
0 Kudos
Message 2 of 4
It is 32 bits windows and no simulink, just direct matlab commands. Indeed my conclusion is that matlab is much more optimized than mathscript.
Unfortunately I still haven't found a way to combine the HMI strength of labview and the computing strength of matlab because of data transfer overhead (transferring data back and forth from labview to matlab is desperately time consuming). Best solution so far is passing data by saving big bin file in labview, pass the file name to matlab, and open it again in matlab. Not so optimized!
0 Kudos
Message 3 of 4

I've never used direct Matlab commands, have always used the Matlab function node, but may have to look into that - and certainly the bin file idea is an interesting one - may have to try that.


I'm using it as we decided to productionise quite a complex bit of software that was done in Matlab and thought we could transpose it all over to LabVIEW/TestStand to save ourselves the cost of a Matlab licence as we have the NI volume licence and also for the reason that you mentioned that LabVIEW does HMI so much better than Matlab - especially when it comes to test, computing strength I can't really comment on as I've never had the opportunity to do a comparison between the two.


For the most part we managed to do it, but certain bits we ended up using Mathscript for and have found it very slow - even at edit time it slows everything down, and as said, another drawback of it is that if you select it when you install LabVIEW then you have to install the 32bit version.

David Clark
IDEX Biometrics UK Ltd
Hampshire, England
0 Kudos
Message 4 of 4