topic Why are mathscript performances much below matlab's? in LabVIEW
https://forums.ni.com/t5/LabVIEW/Why-are-mathscript-performances-much-below-matlab-s/m-p/2369760#M737659
<P>Dear all,</P>
<P> </P>
<P>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.</P>
<P> </P>
<P>I have two choices:</P>
<P>1. use matlab nodes</P>
<P>2. use Mathscript nodes.</P>
<P> </P>
<P>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.</P>
<P> </P>
<P>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).</P>
<P> </P>
<P>Result is that Matlab node version takes 0.5s versus 1.6s for Mathscript node version.</P>
<P> </P>
<P>Why is the performance of mathscript so much below the performance of the matlab node?</P>
<P> </P>
<P>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?</P>
<P> </P>
<P>Thanks in advance for your replies!</P>
<P> </P>
<P> </P>
<P> </P>
<P> </P>Fri, 29 Mar 2013 15:24:04 GMTclapiotte2013-03-29T15:24:04ZWhy are mathscript performances much below matlab's?
https://forums.ni.com/t5/LabVIEW/Why-are-mathscript-performances-much-below-matlab-s/m-p/2369760#M737659
<P>Dear all,</P>
<P> </P>
<P>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.</P>
<P> </P>
<P>I have two choices:</P>
<P>1. use matlab nodes</P>
<P>2. use Mathscript nodes.</P>
<P> </P>
<P>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.</P>
<P> </P>
<P>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).</P>
<P> </P>
<P>Result is that Matlab node version takes 0.5s versus 1.6s for Mathscript node version.</P>
<P> </P>
<P>Why is the performance of mathscript so much below the performance of the matlab node?</P>
<P> </P>
<P>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?</P>
<P> </P>
<P>Thanks in advance for your replies!</P>
<P> </P>
<P> </P>
<P> </P>
<P> </P>Fri, 29 Mar 2013 15:24:04 GMThttps://forums.ni.com/t5/LabVIEW/Why-are-mathscript-performances-much-below-matlab-s/m-p/2369760#M737659clapiotte2013-03-29T15:24:04ZRe: Why are mathscript performances much below matlab's?
https://forums.ni.com/t5/LabVIEW/Why-are-mathscript-performances-much-below-matlab-s/m-p/2384632#M740352
<P>Not sure I can help you, but I have found the same thing.</P>
<P> </P>
<P>I can have a few guesses - are you using 64bit Matlab? if so you may have noticed that MathScript only works in 32bit LabVIEW.</P>
<P> </P>
<P>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.</P>
<P><BR />Third option could simply be that Matlab is a far more optimised commerical product.</P>
<P> </P>
<P>Honest answer is that I don't know!</P>Thu, 11 Apr 2013 08:18:10 GMThttps://forums.ni.com/t5/LabVIEW/Why-are-mathscript-performances-much-below-matlab-s/m-p/2384632#M740352davidpcl2013-04-11T08:18:10ZRe: Why are mathscript performances much below matlab's?
https://forums.ni.com/t5/LabVIEW/Why-are-mathscript-performances-much-below-matlab-s/m-p/2384646#M740354
It is 32 bits windows and no simulink, just direct matlab commands. Indeed my conclusion is that matlab is much more optimized than mathscript. <BR />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!Thu, 11 Apr 2013 08:33:45 GMThttps://forums.ni.com/t5/LabVIEW/Why-are-mathscript-performances-much-below-matlab-s/m-p/2384646#M740354clapiotte2013-04-11T08:33:45ZRe: Why are mathscript performances much below matlab's?
https://forums.ni.com/t5/LabVIEW/Why-are-mathscript-performances-much-below-matlab-s/m-p/2384800#M740378
<P>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.</P>
<P> </P>
<P>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.</P>
<P> </P>
<P>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.</P>Thu, 11 Apr 2013 10:29:58 GMThttps://forums.ni.com/t5/LabVIEW/Why-are-mathscript-performances-much-below-matlab-s/m-p/2384800#M740378davidpcl2013-04-11T10:29:58Z