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!
Solved! Go to Solution.
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!
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.