LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Mathscript in labview 8.0 is slow?

Hello all,

I have been playing with Labview 8.0, in particular the mathscript function.  I am no pro at matlab script but I created 2 simple vi's.  1 with a matlab script and 1 with normal labview coding.  The labview coding seems to be about 20 times as fast as the mathscript I wrote.  Has anyone else noticed this or do I need to work on my mathscript function.  I have attached the two vi's.

Thanks,

Azazel

Azazel

Pentium 4, 3.6GHz, 2 GB Ram, Labview 8.5, Windows XP, PXI-5122, PCI-6259, PCI-6115
Download All
0 Kudos
Message 1 of 5
(4,437 Views)
Mathscript is NOT "matlab script", don't confuse the two. Mathscript is entirely NI but shares some language syntax with matlab.
 
You might want to post this is the Mathscript forum instead. (see also for example this thread)
 
(You are really comparing apples and oranges. Have you compared the speed of a mathscript node with a matlab script node? I don't currently have matlab installed, so I cannot try this.)

Message Edited by altenbach on 10-28-2005 09:33 AM

0 Kudos
Message 2 of 5
(4,429 Views)
I was not comparing against a matlab script...I just wrote that by accident.  Both programs were written using labview and labview functions.



Azazel

Pentium 4, 3.6GHz, 2 GB Ram, Labview 8.5, Windows XP, PXI-5122, PCI-6259, PCI-6115
0 Kudos
Message 3 of 5
(4,418 Views)
In general, LabVIEW 8 MathScript code will execute more slowly than an equivalent algorithm coded using traditional LabVIEW graphical programming. One reason for this is that, unlike LabVIEW, MathScript is not a strictly-typed language. I noticed you enclosed the variables in matrix brackets (e.g. [ ]). Although doing so will allow you to perform Matrix operations with the I32 datatype, the LabVIEW 8 MathScript compiler currently coerces I32 values to DBL before performing the requested operation.

Related to this, we saw a 10% - 20% performance improvement in your MathScript example by
  1. Removing the brackets from your MathScript code
  2. Converting the I32 inputs to DBLs in LabVIEW using a DBL conversion bullet
  3. Changing the output types to DBL 1D
--Sam
Sam Shearman
Message 4 of 5
(4,340 Views)

Hi Azazel,

I second Altenbach in that this thread should belong to the Mathscripts forum.

In any case, I ran at your VIs- with Mathscript and without Mathscript. Depending on how big your arrays are, the Mathscript mode may take a variable amount of time to run but it will always be slower than using a  simple add or subtract function because of the overhead associated with Mathscript node. Ths is true with any structure in LabVIEW. Where ever possible, we recommend that you use simple functions like add or subtract , avoid use of sequences, local and global variables etc as all these features increase the execution time.

Regards,

Ankita 

0 Kudos
Message 5 of 5
(4,334 Views)