06-17-2011 09:47 AM
Hi all,
I have a quite long (500 lines) and complex Matlab code that takes me aprox. 6 seconds to run in Matlab but when I use a Mathscript in Labview to run the same code it takes forever (I quit waiting before it ended).
Is this normal?
After creating an executable file of the Labview with the Mathscript do you think it will run faster?
Another question is:
I want to use fftn() and ifftn() Matlab functions inside a Mathscript in Labview but apparently they are not supported, but this is not stated on the following link:
http://zone.ni.com/reference/en-XX/help/371361E-01/lvtextmath/_rt_suplvtextmath/
One solution I thought is to create DLL from the Matlab code and use them in Labview. What do you think of this? What are the pros and cons?
Any help on these questions would be greatly appreciated.
Thank you very much in advance.
Best regards!
06-17-2011 10:12 AM
One more question:
if I use a Matlab node within a Labview .vi and afterwards I create an .exe from the .vi, will I need to have Matlab installed on the computer or the Matlab Runtime will be enough?
Thank you very much in advance.
Best regards!
06-17-2011 10:18 AM
First, keep in mind that MathScript is not Matlab. MathScript is NI's invention of a language that's similar to Matlab. It's quite possible that something you're doing in your Matlab script works just fine in Matlab, but doesn't in MathScript. That is not at all surprising.
Second, if the issue is with the language, creating an executable won't make it run faster.
Third, that link you pointed to does not list the Matlab functions not supported in MathScript. It lists the MathScript functions that are not supported in the LabVIEW Run-Time Engine. This means those functions will work in a VI that's run in the LabVIEW development environment, but will not work if you build an application. That list has nothing to do with Matlab.
As for creating a DLL, you can go that route, but be aware that you will need the Matlab RunTime installed on the target machine. Also, you will need to stick with simple datatypes as the Call Library Function node does not handle complex data types.
If you use the Matlab script node you will need to have the full Matlab installed on the target engine. The runtime is not enough. The reason is that the script node uses ActiveX to communicate with the Matlab application, not the runtime.
06-17-2011 10:34 AM
smercurio_fc,
thank you very much for your reply.
Regarding the DLL creation, are 2D matrices considered simple datatypes?
Do you know how to create the DLL files from Matlab?
Thank you very much in advance.
Best regards!
06-17-2011 10:46 AM
You don't direcly say which version of LabVIEW you are using, but your link is pointing to the LabVIEW 8.6 help which is very old.
Mathscript added support for more functions and also got significantly faster in newer versions.
What does your program actually do? Who wrote it? Often, there are native LabVIEW functions that can be substituted.
To get help creating a dll from matlab, you probably would need to ask in their forum.
06-17-2011 11:13 AM
I'm using Labview 2010.
I'm unwrapping a phase map obtained from an interferometer...
I wrote it.
I'll check the DLL creation, but do you think handling 2D matrices might be problematic?
Thank you.