LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to define a function in the MathScript Node

Is it possible to define a function in the MathScript Node
0 Kudos
Message 1 of 3
(2,741 Views)
You might want to ask this over in the MathScript Forum 🙂
0 Kudos
Message 2 of 3
(2,733 Views)

You can not define a function inside of a MathScript Node, but only because it isn't necessary. The way custom functions work in MathScript is that they are saved in .m files located in paths in the MathScript path list. When the MathScript compiler receives a function that it doesn't recognize, then it searches for it in the path list, and upon finding it, compiles and loads the function. You can specify these search paths manually by going to File>>MathScript Preferences from the MathScript Window or dynamically by using the path() command within a script.

To answer your original question, if you would like to create custom functions dynamically within a VI, then you can simply build your custom functions using strings and then save them to an ASCII file with the extension .m. You could either save the file to a path already in the MathScript path list or you could dynamically specify the path by passing the path into a MathScript Node as a string and by using the path() command at the beginning of your script to set it.

Kind Regards,

E. Sulzer
Applications Engineer
National Instruments
0 Kudos
Message 3 of 3
(2,717 Views)