How to invert .p file to .m file

254 views (last 30 days)
file123 on 13 Feb 2018
Answered: Walter Roberson on 29 Aug 2023
I have a file with a .p extension. How can I convert to .m file?
recent works
recent works on 3 Nov 2022
not possible. only .m files to .p files possible.
Babawuya on 29 Aug 2023
Moved: Bruno Luong on 29 Aug 2023
how can i convert a matlab p-code file to m file

Sign in to comment.

Accepted Answer

ES on 13 Feb 2018
You cant do that.
Steven Lord
Steven Lord on 13 Feb 2018
If you're not sure what your professor has asked you to do, you probably need to ask them to clarify.
From the portion of your assignment that you've quoted, it doesn't sound like your professor wants you to reverse engineer the signal1 function. It sounds like they want you to treat it as a "black box" and write code that uses the signal that black box emits.
Stephen23 on 13 Feb 2018
"How can i solve this problem?"
What problem? You can use that .p file without converting it to anything else (that is the whole point of them). The task you were given even tells you exactly how: "To evaluate this function, simply type y = signal1(t) where t is a vector containing values of time".

Sign in to comment.

More Answers (3)

recent works
recent works on 3 Nov 2022
not possible. only .m files to .p files possible. mainly .p files helps to protect the important files

Benjamin Kraus
Benjamin Kraus on 13 Feb 2018
By design, there is no way to convert a P-coded file (a file with the .p extension) into a regular MATLAB file (a file with the .m extension). The conversion from MATLAB file to P-coded file is a one-way conversion. As the description on the pcode doc page ("Create protected function file") states, the purpose of creating a P-coded file is to obfuscate the code to protect the source code. If you could reverse the operation, there would be no point in converting to a P-file.

Walter Roberson
Walter Roberson on 29 Aug 2023

There is no documented way to convert p files to m files, and Mathworks will not assist you in converting files.

There have been at least three versions of p files. The first version was in use until about 2010. The second version was in use until a small number of releases ago, and the third version is now in use.

A small number of people outside of Mathworks demonstrated that they were able to convert version 2 p files to m files. None of the people who I was aware of ever provided a commercial service to do the conversion. I was aware of one person who provided a free service, but stopped doing so a number of years ago.

Whether it is legal for people outside Mathworks to convert third-party p files to m files depends on the jurisdiction. In the USA, the encoding done to produce p files would definitely qualify for protection in law, and so in the USA the only people legally permitted to decode third party files would be qualified security researchers, or university students in computer security courses acting under the direction of qualified security researchers — or, people with disabilities who were adapting programs for use with assistive devices for their own personal use (yes, this does mean that if you are someone who physically cannot do the adaptation then you cannot get anyone to do it for you! It is not a good law.)

The laws are different in some other countries, especially Germany, but the relevant laws are mostly driven by entertainment companies (copy protection / digital rights) who have managed to create fairly powerful lobbyists, so the laws are a fair bit more restrictive in many countries than most people would expect.


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!