Hello friends, I hope you all are doing great. In today's tutorial, I am going to show you How to Convert m File into p File in MATLAB. Now the question arises that why we need to do that? & the answer is if you want to protect your code and don't want anyone to access it then you need to your Convert m File into p File. P File is like an encrypted file which performs the same functionality as your original m file but no one can get the code out of it.
Like me explain it with an example, suppose you are some sort of developer and you have created some code for a company and now you want to protect your code and just send the company some sort of software. MATLAB has a function in which you convert your m-file into p-file and no one can open that p file code. P-file functionality is as same as of m-file but no one can check what's inside p-file.
Convert m File into p File in MATLAB
Suppose you have created your m-file and you are now want to protect your code and the send the rest to your employer so that he can use it without knowing the code inside it.
Use these command to do this :
pcode(fun)
pcode(fun1,...,funN)
If fun is the name of the m-file then MATLAB will conver the fun.m to fun.p and create it in the same folder.
If fun is the name of the folder then MATLAB will convert all the m-files within that folder into p-files.
If you want to convert more than one m-file into p-file then use the second code and place all the m-files there.
You can also convert more than one folder using the second command.
So, that's all for today. In my next post I will tell you a way of protecting your simulink model in the same way as we protected our m-file. Till then take care & stay blessed .... :))
syedzainnasir
I am Syed Zain Nasir, the founder of The Engineering Projects (TEP). I am a
programmer since 2009 before that I just search things, make small projects and now I am sharing my
knowledge through this platform. I also work as a freelancer and did many projects related to
programming and electrical circuitry. My Google Profile+Follow
Get Connected
Comments on ‘’ Convert m File into p File in MATLAB ‘’ ( 2 )
0
Says:
@ Jia Khan This problem is because of some programming issue .... as it shows you have some empty string in your m-file which is making problem .... debug your code at line 80 ...
If the problem still remains let me know ... I will find some other solution ..... and its better if you first convert a simple m file into p file for just your testing ....
Reply
100
1
Says:
??? Error using ==> pcode at 80 Input argument must be a nonempty string. IT GIVES THIS ERROR PLEASE HELP ME
Reply
If the problem still remains let me know ... I will find some other solution ..... and its better if you first convert a simple m file into p file for just your testing .... Reply
Input argument must be a nonempty string.
IT GIVES THIS ERROR PLEASE HELP ME Reply