MATLAB: How to password-protect functions and scripts

MATLABpassword read-only protect block

A group of colleagues and I have put together a group of functions and scripts. Eventually we started having several parallel versions of the program because of non authorized/notified changes in the functions. Is it possible to password-protect the files? I'd like to set something so that all the files can be used and executed but the only way to modify them is if two or more users get together and input their passwords. We're using Matlab R2016b on Windows 10.
I found someone asking the same question in Mathworks but the alternative given for him does not work for me (a backup followed by a comparison and if the files have been modified, they would be restored)
Any suggestion will be appreciated, thanks.

Best Answer

You can pcode the files and distribute the p files which cannot be edited (by anybody). If the file needs to be modified, then only those with the original m files can modify them. After modification, you'll have to redistribute the new p files.
As plain m files, matlab does not offer any facility to set files read-only as that is a function of the OS.
However, I would say that trying to solve your process problem with technical means within matlab is the wrong approach. For a start, why aren't using version control? With subversion and git having been integrated into matlab for a while now, there's no excuse not to. You can then put out a policy that only unmodified ckeck outs from version control are allowed to be used. You can even modify your code so that with its outputs it also include the version used to generate the outputs (and whether or not it was pristine). I do that with my code.