Protect Simulink Design in MATLAB
Hello friends hope you all are healthy and enjoying good health. In today's tutorial, I am going to share How to Protect Simulink Design in MATLAB and in order to do so I have used S Function method. In my previous post I have explained
How to Protect your m-file Codes in MATLAB by converting it to p-file so that no one can reach to your code and now I am gonna explain how to protect your simulations in MATLAB which you create in Simulink so that your intellectual work wont go waste.There are many methods to protect the Simulink simulations and the easiest of them is using S-function. Now follow these simple steps and it won't be much difficult.
Protect Simulink Design in MATLAB
- Open the simulation which you want to protect. Make sure you are done with the simulation and don't need any more editing. As after conversion you wont be able to edit it.
- Now select whole of your simulation and right click on it.
- Click on the Create Subsystem in right click listing.This will create a single block for your whole system.If you double click click this block a new window will pop up and you can see your whole model again.
- Now right click on this newly created subsystem block and then in the listing click on Real Time Workshop and the Generate S-Function.
- On clicking a new window will pop-up add variables if you want to control any otherwise just tick the corner which says Use Embedded Coder and hit Build.
- It will take few seconds to build the S-function for your simulation and when its done Hurrah your simulation is now protected.
- Now double click on your subsytem and you won't be able to open your design, instead a window pops up which will give some description.
- You can add the complete description while generating your simulation.
- Now start your simulation , it will work fine but no one could find your design.
Note :
- This method is mostly used by the developers to protect their simulations.
- Users can use their simulation but couldn't get the design of it, the design got fully protected.
Convert m File into p File in MATLAB
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 .... :))