02-06-2009 01:52 PM
Hello,
just uppgraded to Labview 8.6 and particularly amazed about Mathscript. Finally Labview has it all !
I am learning from two examples provided with Labview. The Mathscript using Riemann Zeta.vi and the Mathscript using shared libraries. Since i have some m fonctions i'll start with the first example.
In the Riemann Zeta Mathscript node, we can read the following:
a = cputime;
z = zeta(0.5+(k)*(35/n)*i);
b = cputime;
c = b-a
The function zeta is saved in a .m file as a normal matlab function and is located in the same folder as the vi. When i tried to reproduce the same (write a code in the Mathscript node that calls a .m function saved in the same folder) LabVIEW is not recognizing the .m function. A red cross is appearing at the start of the line code that calls the function.
Any reason or way to fix that?
In the second example, Mathscript using shared libraries, the node loads a library "mydemo.dll" and "demo.h". My question in not directly on Labview here but on the shared libraries since I have limited information on them. Are they activeX dll ? Are they written in C++ ? Is there a way to compile my m functions in a dll ? what is the recommended language to create shared dll libraries? Any external tutorial on shared libraries is very much appreciated.
Thank you very much
Sam
02-06-2009 01:58 PM
Please find attached the file codes related to the meantioned examples
Sam
02-06-2009 04:55 PM
02-09-2009 09:05 PM
Hello Grant
your reply is very helpful. I did not explicitly search for calling user-defined functions, but i did read many tutorials on Mathsripts (window and node) and i don't remember i read anything about search path. Then i started learning from the examples.
While testing my functions in the Mathscript node i noticed two facts:
a variable cannot be of the same name as a function. (for example: `GetText=GetText (argument)` is not allowed)
the function should not finish with "end"
Hope it helps !
Cheers
02-10-2009 08:50 AM
02-10-2009 09:15 AM
Hello Grant,
I don't have any reason to use same variables as function names and i agree that it's not a good practice. I just wanted to point out some of the differences between the Matlab syntax and MathScript, that i have been discovering by trial and error.
Now what i want to make sure of is the fact that all outputs of a Mathscript node are updated at the end of the exectution of the code inside the node. For instance, if A and B are inputs, C an output
C=A+B;
pause(5);
C=A-B;
In labview C will have the value A-B. The update of C is done once at the end of the code and not sequencially. I guess i'll have to create a sequence struture in Labview and repeat the Mathscrip code.
Thank you
Sam
02-11-2009 12:50 PM
Hello,
Here is an example about calling external functions with Mathscript node:
http://zone.ni.com/devzone/cda/epd/p/id/4788
The path issue is explained in the block diagram
02-16-2009 09:33 AM
07-24-2009 01:31 AM
Hi Grant,
Regarding Mathscript documentation, I would like to ask how to find help about which algorithm is used for the left matrix division operator.
I'd like to know what does Mathscript do when the matrix is rank deficient?
Thanks
07-24-2009 04:15 AM
Hi Joshuak,
MathScript returns LS solution when matrix is singular.