05-15-2012 09:51 AM
Good morning.
I am developing MATLAB algorithms containing functions and subfunctions. To integrate them in LabVIEW, I plan to use Mathscript nodes. And if I do so, I have to leave the subfunctions .m files in a repository on the PC (right?).
My problem is that I do not want to reveal these easily readable files when deploying my LabVIEW code. So I am looking for a way to deploy this code without making my source code available and open to all.
Thanks for any help!
05-15-2012 12:18 PM
What if you put the Mathscript portion in a subVI, then just password protect that subVI?
05-15-2012 12:19 PM
Hi,
May be not possible..
05-15-2012 12:42 PM
Ravens Fan wrote:
What if you put the Mathscript portion in a subVI, then just password protect that subVI?
Hello Ravens Fan. Can a Mathscript node read subfunctions from a subVI? I haven't found anything describing how to do that...
05-15-2012 12:57 PM
I think Ravens Fan was referring to actually putting the MathScript code inside a MathScript node, not leaving it as its own file. That way the code is saved with the VI.
You started out by saying you're developing Matlab algorithms. You should keep in mind that MathScript and Matlab are two different languages. While there are many similarities, there are also a lot of differences, and Matlab code is definitely not 100% compatible in MathScript. Thus, if you write the code in Matlab there is no guarantee it will even work in MathScript.
05-15-2012 01:44 PM
Thanks smercurio.
@smercurio_fc wrote:
I think Ravens Fan was referring to actually putting the MathScript code inside a MathScript node, not leaving it as its own file. That way the code is saved with the VI.
Please allow me to illustrate my question through an example.
Let's say my code is script S1. S1 contains functions f1, f2 and f3, f1 contains subfunctions sf1 and sf2, and so on. I end with a code structure looking like this one (all .m files):
S1
- f1
---sf1
---sf2
-f2
---sf3
-f3
---sf4
---sf5
If S1 is copied in a Mathscript node, how can it work without leaving f1.m, sf1.m and others available on the user's pc after deployment?
Now, as I understand from my readings and my experimentations, when I put the function and subfunction files in the "LabVIEW Data" file, the functions name in the script S1 copied in a Mathscript node will appear in purple (by default). The node executes fine then. But if I copy the functions in Mathscript nodes in other VIs, the functions name appear in grey, and the node won't work. I don't know how to point to these other Mathscripts... Is there something I miss here?
@smercurio_fc wrote:
You started out by saying you're developing Matlab algorithms. You should keep in mind that MathScript and Matlab are two different languages. While there are many similarities, there are also a lot of differences, and Matlab code is definitely not 100% compatible in MathScript. Thus, if you write the code in Matlab there is no guarantee it will even work in MathScript.
Thanks for the warning. I tried my algorithms using the method described above, and they work well.
05-16-2012 12:33 PM
@DCanQAlias wrote:
@smercurio_fc wrote:
You started out by saying you're developing Matlab algorithms. You should keep in mind that MathScript and Matlab are two different languages. While there are many similarities, there are also a lot of differences, and Matlab code is definitely not 100% compatible in MathScript. Thus, if you write the code in Matlab there is no guarantee it will even work in MathScript.
Thanks for the warning. I tried my algorithms using the method described above, and they work well.
Still, even though the algorithms work well, for now I have to leave my proprietary code in the open.
Would the only way be to convert the MATLAB code to LabVIEW graphical code?
05-16-2012 12:51 PM
You could compile your Matlab code into a DLL (I'm assuming you're using Windows) and then call it from LabVIEW using the Call Library Function Node. The target computer would require the Matlab Runtime engine, and you'd need to use the Matlab compiler (which I believe is a separate purchase).
05-17-2012 10:06 AM
Hey DCanQAlias,
Would locking the block diagram and then password protecting your .m files encapsulate your proprietary code enough?
Here are two links articles that talk about protecting block diagrams on VIs.
Password Protection vs Removing Block Diagram
You can also try some of the other suggestions that people have mentioned above.
Hope this helps!
Joe S
Applications Engineer
National Instruments
05-17-2012 11:11 AM
Hi Joe,
That could be a good compromise, I think.
Do you know a way to password protect a .m file which will remain accessible to the Mathscript nodes and other .m files, but not to the users?
Thanks!