How to open a .p file in matlab ?

1 391 views (last 30 days)
sindhura c
sindhura c on 10 Jan 2019
Edited: Jan on 6 Sep 2021
I have a file with extension .img whick is of around 70MB and a .p file to view them
I need to open / view the images using matlab.
Please help me out on this

Answers (3)

Jan
Jan on 6 Sep 2021
Edited: Jan on 6 Sep 2021
You cannot "open" a P-file in a meaningful way. Modifications are not possible.
If you want to change the code of a P-coded function, you have to ask the author to do this for you. Maybe he is willing to share the original M-file with you, maybe he is not.
P-coding includes an encryption. Of course any encryption can be hacked, but this would be illegal.
[EDITED] To clarify the last sentence:
  • According to the documentation, P-coding is an "obfuscation", not an "encryption".
  • Following Bruno's arguments in the comments below, it is legal in Europe to decompile P-code.
  • MathWorks does not want the algorithm of P-coding to made public and it would be a drawback for many programmers, who have tried to protect their codes. So even if it is legal, there would be good reasons not to publish corresponding instructions.
  • Legal, illegal, allowed, not wanted, useful for one person but a drawback for many - sigh.
  4 Comments
Bruno Luong
Bruno Luong on 6 Sep 2021
Edited: Bruno Luong on 6 Sep 2021
From the from the source :
"Article 4 of the Directive sets out the exclusive rights of the author, including the rights to translation, adaptation, arrangement, any other transformation and reproduction of the program. "
"Decompilation is a type of reverse engineering of software, namely, converting executable, computer-readable code (known as object code) into a human-readable code (thus recreating the source code through a higher-level programming language). "
Therefore transforming p-code (object code) to m-code (source code) would be considered and decompilation and perfectly legally allowed in EU for fixing error purpose, if this is Sarib Malik intention, even without author authorisation.
Jan
Jan on 6 Sep 2021
Edited: Jan on 6 Sep 2021
@Bruno Luong: Thanks for the explanations. Following your legal arguments, the Sarib Malik is allowed to decompile P-code inside Europe. It was not my intention to allege, that the he has any illegal intentions.
I'm not in the position to offer assistence for such a decompilation, maybe for legal reasons, maybe following the common sense, maybe it is my respect for the intention of MathWorks and many programmers who want to keep their codes hidden, maybe I like to avoid getting or making troubles beyond the chances to win the lawsuit, maybe I do not have running code. I would not hesitate to decompile P-files, if I'm the author of the source codes. But a revealing of the algorithm in a public forum would mean loosing a tool (with limited power) for all Matlab users. And, of course, the Matlab team would not like me anymore ;-)
I've added a corresponding explanation to my answer.

Sign in to comment.


Walter Roberson
Walter Roberson on 10 Jan 2019
.p files are MATLAB functions with source code you cannot read. You can call them as functions by mentioning their base name without the .p extension
result = NameOfPFileHere('NameOfimgFileHere.img');
  8 Comments
Jan
Jan on 6 Sep 2021
@Sarib Malik: Before you get too confused: Walter's code does no do, what you try to do. It is not possible to manipulate the contents of a P-file in a meaningful way.
Walter Roberson
Walter Roberson on 6 Sep 2021
Suppose that you had a letter in English, and you found someone to translate the letter to Linear B, and then once in Linear B they converted it into Morse Code For Linear B, and gave you back a file of that Morse Code For Linear B.
Now, under that circumstance could you look at the contents of the file? Yes -- and you would see a bunch of dashes and dots. Could you modify the file? Yes -- you could change any of the dashes and dots or even insert more dashes and dots. But would the modified file be useful?? When you do not yourself know either Linear B nor Morse Code for Linear B ?
You can read .p code files. You can change .p code files. However, no tools are available to be able to deal with the meaning stored in the file.

Sign in to comment.


KSSV
KSSV on 10 Jan 2019
You cannot open a .p file...you can only use it......
  3 Comments
Sarib Malik
Sarib Malik on 5 Sep 2021
how we can change or modify .p file?
Jan
Jan on 6 Sep 2021
@Sarib Malik: Did you read the answers and comments? Let me repeat the message:
You cannot modify a P-file in a way, which allows to use it afterwards.
P-coding is the method in Matlab to hide the source code and to prevent further modifications. This is useful e.g. to keep an intellectual property private. For this purpose the P-files are encrypted. While you still can modify bytes of encrypted files how ever you want, you cannot expect that the result is still meaningful.

Sign in to comment.

Categories

Find more on Programming in Help Center and File Exchange

Products


Release

R2015a

Community Treasure Hunt

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

Start Hunting!