2

If a company works on matlab projects, then how do they provide the client the project? I mean which file do they send to the client as they cannot hand over the client the whole codes and data ?

anurag
  • 79
  • 1
  • 7
  • 2
    Have you looked at [`pcode`](http://www.mathworks.com/help/matlab/ref/pcode.html)? – Shai Dec 08 '14 at 06:19
  • This post by Sam Roberts may also help: http://stackoverflow.com/questions/18126407/matlab-compiler-vs-matlab-coder – rayryeng Dec 08 '14 at 07:18

2 Answers2

4

It would depend on lots of things, such as the nature of the product you are building for the client, your relationship and contractual agreement with them, and whether they need to modify the product in the future.

When I carry out consultancy on MATLAB projects for a company, I usually supply them with MATLAB source code. Part of the contract would typically say that they own the code (and the copyright to the code) that I produce for them, and they can then do pretty much whatever they want with it.

If you have a different relationship, where you continue to own the code and need to prevent them from reading it and/or modifying it, then the issue is really the same as it is for any other language: you rely on a mixture of technological restrictions and legal restrictions, designed to be as restrictive as you need while minimizing inconvenience for the end-user.

For example,

  1. You can obfuscate your code using the command pcode. That will prevent almost everyone who isn't extremely determined from seeing your code and modifying it (there are some loopholes though), but they will still be able to run it within MATLAB. Downsides might be that your code may become unexecutable in a future version of MATLAB, so you may need to support it again to fix that later. To mitigate this, you could specify in your contract or license agreement that only specific versions of MATLAB will be supported.
  2. You can use MATLAB Compiler to produce a standalone library or executable that contains the code in an encrypted form. Downsides might be that they would rather use the code from within MATLAB. An upside would be that unlike the first option it doesn't require MATLAB, so you're not vulnerable to backward-compatibility issues in future.
  3. You can include licence-management code within your MATLAB application. You can either roll your own, perhaps by calling a bit of Java for the cryptography (you will likely not be able make it very secure, unless you're very talented, but you'll probably be able to make something simple and workable), or you can buy third-party C libraries that do it well, and call them from MATLAB.
  4. You can simply put copyright lines in your code saying that you own the copyright, and licence the code to them under specific terms, such as that they may view it, use it, but not modify or redistribute it. If you really want, you could ask them to also sign a non-disclosure agreement requiring them not to discuss the content of the code with third parties.

Although the technological restrictions available are a little different in MATLAB than they would be for a compiled language such as C or Java, at the end of the day those are only ever there to keep honest people honest - anyone determined will be able to get around them eventually, and they may well inconvenience the honest people, annoying them into disliking your product or service.

Better to use a mixture of very light technological restrictions, crystal-clear contract and licensing terms, and trust.

<advert> One of the consultancy services I offer is advice and help in preparing MATLAB code for deployment, including protecting it. If you think you'd benefit from that, please get in touch. </advert>

Sam Roberts
  • 23,951
  • 1
  • 40
  • 64
  • Another downside of #2 is that it would be platform-dependant so you'd need to compile out versions for each OS (and 32-/64-bit in some cases maybe). There is also [some toolbox functionality that Matlab Compiler doesn't support](http://www.mathworks.com/products/compiler/supported/compiler_support.html;jsessionid=a3d34359fc44dfda0912446eed2d). – horchler Dec 08 '14 at 14:12
0

You can use the Matlab Compiler and compile your codes in to an exe file for windows. This is what is usually expected by a company. Some who have R&D themselves might ask you for the original m-code, or specific functions depending on your relationship/contract with them. I've been asked to give m-code several times, and it says on my contract that I am suppose to give this information to them. (UK based)

GameOfThrows
  • 4,510
  • 2
  • 27
  • 44
  • If I convert it to .exe, then how would matlab run it? If it works in cmd, then how to convert the same ? – anurag Dec 08 '14 at 10:10
  • @anurag, the source code used to make the .exe still exists in the source code form on the developer's site which can be used to run from .m or the .exe. The whole point of 'delivering to a client' is that you don't suppose that they have MATLAB to run in the first place. If they do, the .exe protects your IP – Vass Jun 28 '18 at 01:26