Where do you want to store the number of performed iterations? Any changes on the hard-disk can be reset easily, therefore neither a file nor the registry (also a file...) is a save location. Storing the counter in the memory is very volatile also.
Therefore you have to control the counter on your own internet server and the user needs an active internet connection. This is an even more brute control than Microsoft, Adobe and MathWorks have invented to protect their software.
Encrypting the code is fragile also: Matlab is an interpreted language and the debugger and overloaded built-in function can reveal, what's going on inside your code. Methods for restricted access can be cheated easily in consequence.
Even the encrypted boot-loader of the Galaxy S4 has been hacked after 4 week already. Here it was not required to decrypt the program, but moving it around in the memory until the function for the test of the signature is at a certain location, where it can be replaced by a trivial function, which replies, that the code has passed the tests. And remember, that there are a lot of millions of dollars behind Samsungs phones.
Therefore my conclusion is easy: Forget it. There are no stable restrictions in Matlab, which require more than 30 minutes to be broken. Developing a program, which controls the access through an encrypted internet connection to a server you own, is much more expensive than these two solutions:
- Buy a used laptop, install Matlab, P-code your functions, determine a hardware ID (see http://undocumentedmatlab.com/blog/unique-computer-id/ ), hard-code it into the P-file. Then borrow the laptop for a week only. Customer hesitate to steal hardware, while software is copied without qualm.
- Setup Matlab locally and let the customer run the program through a TeamViewer session or any other remote desktop service.