11-18-2008 10:58 AM
So I'm tasked with getting some MathCAD documents converted into Mathscript so they can be easily used in my LabVIEW programs. Looking over the documentation I have the following concerns:
1. Is it possible to define a function in a MathScript node? This does not appear to work in the same way as in Matlab. I don't want to have a .m file for each of my functions. I'd rather define them all in the MathScript node.
2. The whole "search" path thing is crippling to code portability. Why can't location of my VI be part of the search path for .m function files.
3. Lack of indentation features :(. How can I write a text program without a way to indent?
I'm sorry, but this is kinda crappy. Please tell me that these things are supported and I'm just ignorant.
-Nic
11-18-2008 11:35 AM
11-18-2008 11:39 AM
11-18-2008 12:02 PM
"NOTE: Changes you make to the search path list apply only to the MathScript Nodes in the main application instnace." 😞 😞
Is MathScript still in beta? Are we beta testing for National Instruments or something? I'm sorry, but this is just sad. This is suppose to be one of those "reasons" to get the Professional version over the base version of LabVIEW... it just leaves a lot to be desired.
11-18-2008 02:16 PM
Nickerbocker wrote:Is MathScript still in beta?
Mathscript is a relatively recent addition to LabVIEW, and as such does not have the same legacy as plain G code. Still, it seems to work pretty well for most of us.
Mathscript received significant improvements in 8.6. What version do you have?
Personally, I tend to do everything with wires, because my brain does not work well within the confines of the limiting abstraction of text based code. Have you tried implementing your algorithm with wires instead? What are you actually trying to do?
If you feel you have a good idea on how to improve the software, I would strongly recommend to use the product suggestion center. 🙂
11-18-2008 02:50 PM
Thanks for the reply. I'm running LabVIEW 8.6 (although I'm considering going back to 8.2, due to the buggy mixed signal graph indicator). I have a few suggestions for NI on how they can improve Mathscript...
I got my code to run in LabVIEW, but it was a bit of a struggle. I programmed for a couple of years using Matlab, and constructs are implimented a little differently.
Ultimatly, I think I am most dissapointed in the awkwark imlementation of the m-file paths. This could be easily solved if the directory of the LabVIEW VI was automatically the first place to look for m-files (as it is in Matlab). If I wanted to share my VI's and m-files with someone, I would have to explain how to put those m-files in their MathScript path. Oh, right...if they need to debug it in the MathScript window they have to add the directory by using the "addpath" command <<sigh>>.
There are also some language differences. LabVIEW cries foul with the "end" statement at the end of my function code, but for Matlab this is something to be expected. I can have subroutines and functions in one file, but I can't have my "main" code in that same file. So I have a "mymain()" function that contains my code, and the supporting functions beneath it. Then in my MathScript block, i just call this mymain() function and supply the arguments that are wired to the block.
I would prefer to just have the code in the MathScript block, because that would give me easier access to it and the ability to troubleshoot my overall code quicker.
11-18-2008 04:16 PM
11-18-2008 04:39 PM - edited 11-18-2008 04:39 PM
Hi! Thanks for your reply Grant. I'll fill out a suggestion form when I get a chance and have gathered my thoughts some more. I do get an error with the "end" at the end of a function. I'm pretty sure that it is a requirement in Matlab, but I do not own Matlab so I cannot verify.
I think NI should strongly the feature of searching for m-files in the working folder that a calling VI is saved in. Matlab may require a "cd" command, however there is an obvious indicator of the working directory and this is integrated with the script editor file browser which makes it more-or-less transparent. Basically, if I'm in Matlab and i send a buddy a number of .m files he can decompress them and use them with ease. Just like in C programming, there are just rational assumptions to be made about other files that exist within the same folder.
I do like your suggestion of implementing the "cd" command using an input string that contains the current VI's folder. It is a shame that this comes at a performance cost...I'm a little confused as to why this is but because of it I am reluctant to use it (most of my mathscript will be executed within LabVIEW loops).
I got my code working. I used an external text editor with a tab feature to do it. But it works, all the same.
11-19-2008 04:20 PM