Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to convert p code to m-file

2,742 views
Skip to first unread message

Saravanan Mani

unread,
Feb 10, 2010, 6:56:04 AM2/10/10
to
I need to convert p-file in own source m-file, are there some methods?

Wayne King

unread,
Feb 10, 2010, 7:26:05 AM2/10/10
to
"Saravanan Mani" <saravan...@gmail.com> wrote in message <hku6sk$e9q$1...@fred.mathworks.com>...

> I need to convert p-file in own source m-file, are there some methods?

Hi, are you asking how to pcode your own MATLAB source code, so that you can obscure the content and share it with others? Then look at
>>doc pcode

If you are asking how to obtain the MATLAB source code for some .p files someone has given you....well, if someone has taken the effort to pcode their MATLAB programs, it is because they are attempting to protect their (and possibly others') work. They may have very good reasons for doing this, e.g. it is required by their employer, and therefore you should contact the author of the code and see if they will provide you the source code, rather than attempting to obtain the source code in an unethical manner.

Wayne

Steven Lord

unread,
Feb 10, 2010, 8:06:42 AM2/10/10
to

"Saravanan Mani" <saravan...@gmail.com> wrote in message
news:hku6sk$e9q$1...@fred.mathworks.com...

>I need to convert p-file in own source m-file, are there some methods?

Going from an M-file to a P-file? Use PCODE.

Going from a P-file to an M-file? You will need to ask the person who gave
you the P-file if they want to give you the M-file from which the P-file was
generated. If you're the person who generated the P-file and you've lost
the M-file from which it was generated ... then you're out of luck.

--
Steve Lord
sl...@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ


mat001

unread,
Feb 10, 2010, 9:05:21 AM2/10/10
to
"Saravanan Mani" <saravan...@gmail.com> wrote in message <hku6sk$e9q$1...@fred.mathworks.com>...

> I need to convert p-file in own source m-file, are there some methods?


You can not convert p to m in principle. pcode just a protection layer over the m files.
protection layer not code.
Do not try better to ask the person if you really need his code.

Steve Amphlett

unread,
Feb 10, 2010, 10:29:05 AM2/10/10
to
"mat001 " <priya....@gmail.com> wrote in message <hkuef1$i8m$1...@fred.mathworks.com>...

Not strictly true. It's not a layer OVER the m-files. They're history and cannot be reconstructed.

mat001

unread,
Feb 11, 2010, 4:46:04 AM2/11/10
to
"Steve Amphlett" <Firstname...@Where-I-Work.com> wrote in message <hkujc1$a4f$1...@fred.mathworks.com>...

what do u mean by history here?
can you explain little more.

Steve Amphlett

unread,
Feb 11, 2010, 4:57:02 AM2/11/10
to
"mat001 " <priya....@gmail.com> wrote in message <hl0jks$61v$1...@fred.mathworks.com>...

I mean that the donor m-file cannot be reconstructed or extracted. It's a one-way trip.

Jan Simon

unread,
Feb 11, 2010, 8:37:02 AM2/11/10
to
Dear Saravanan!

> I need to convert p-file in own source m-file, are there some methods?

You can inspect the contents of a P-file and the communication with other functions using the debugger of Matlab. For P-files of Matlab 6 there are some further techniques to get the contents of the original file, but for the modern Matlab versions the P-files are encrypted.

The main problem is usually the conflict with the license conditions of the program!
In every case, digging in a P-code takes usually much more time and knowhow than re-programming it! So my first approach would be to offer 1000$ (or more) to the author to send me the M-file. If it is not worth to spend this money, forget it.

Kind regards, Jan

Steven Lord

unread,
Feb 11, 2010, 9:58:49 AM2/11/10
to

"Steve Amphlett" <Firstname...@Where-I-Work.com> wrote in message
news:hl0k9e$gso$1...@fred.mathworks.com...

Assuming you overwrite or delete the existing M-file explicitly after
generating the P-file, that's correct. However, if you call it on its own
PCODE creates a new file with the extension .p and so your existing file is
fine.

>> ls

. mytestfcn.m
..

>> pcode mytestfcn.m
>> ls

. mytestfcn.m
.. mytestfcn.p

0 new messages