MATLAB: As the administrator of a Windows PC, can I create a Matlab code that a user can execute, but that this user cannot neither read nor copy

executablenot readable

Example: I write a code AAA.m, which calls another one, BBB.m. I want the user the be able to edit/modify AAA.m and to run it, which needs Matlab to be able to call BBB.m, but I want to prevent the user from reading and copying BBB.m.

Best Answer

Let's call the "open" code AAA.m, and the code to be protected BBB.m, which is called by AAA.m. At the beginning of BBB.m, test the Matlab license number with 'license()', e.g.: number=license(); if number=='012345' (supposing that the true license number is 012345) "do what the code has to do" else "do nothing or calculate an output variable with a wrong format" end. Then, pcode('BBB.m'). That's all! When launching AAA.m, BBB.p will be called and will return something that will cause AAA.m to crash. Even the reason of crashing will remain unknown by the user.