Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
how to convert p code to m-file

Subject: how to convert p code to m-file

From: Saravanan Mani

Date: 10 Feb, 2010 11:56:04

Message: 1 of 9

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

Subject: how to convert p code to m-file

From: Wayne King

Date: 10 Feb, 2010 12:26:05

Message: 2 of 9

"Saravanan Mani" <saravanan.ms55@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

Subject: how to convert p code to m-file

From: Steven Lord

Date: 10 Feb, 2010 13:06:42

Message: 3 of 9


"Saravanan Mani" <saravanan.ms55@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
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ

Subject: how to convert p code to m-file

From: mat001

Date: 10 Feb, 2010 14:05:21

Message: 4 of 9

"Saravanan Mani" <saravanan.ms55@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.

Subject: how to convert p code to m-file

From: Steve Amphlett

Date: 10 Feb, 2010 15:29:05

Message: 5 of 9

"mat001 " <priya.biomath@gmail.com> wrote in message <hkuef1$i8m$1@fred.mathworks.com>...
> "Saravanan Mani" <saravanan.ms55@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.

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

Subject: how to convert p code to m-file

From: mat001

Date: 11 Feb, 2010 09:46:04

Message: 6 of 9

"Steve Amphlett" <Firstname.Lastname@Where-I-Work.com> wrote in message <hkujc1$a4f$1@fred.mathworks.com>...
> "mat001 " <priya.biomath@gmail.com> wrote in message <hkuef1$i8m$1@fred.mathworks.com>...
> > "Saravanan Mani" <saravanan.ms55@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.
>
> Not strictly true. It's not a layer OVER the m-files. They're history and cannot be reconstructed.

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

Subject: how to convert p code to m-file

From: Steve Amphlett

Date: 11 Feb, 2010 09:57:02

Message: 7 of 9

"mat001 " <priya.biomath@gmail.com> wrote in message <hl0jks$61v$1@fred.mathworks.com>...
> "Steve Amphlett" <Firstname.Lastname@Where-I-Work.com> wrote in message <hkujc1$a4f$1@fred.mathworks.com>...
> > "mat001 " <priya.biomath@gmail.com> wrote in message <hkuef1$i8m$1@fred.mathworks.com>...
> > > "Saravanan Mani" <saravanan.ms55@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.
> >
> > Not strictly true. It's not a layer OVER the m-files. They're history and cannot be reconstructed.
>
> what do u mean by history here?
> can you explain little more.

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

Subject: how to convert p code to m-file

From: Jan Simon

Date: 11 Feb, 2010 13:37:02

Message: 8 of 9

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

Subject: how to convert p code to m-file

From: Steven Lord

Date: 11 Feb, 2010 14:58:49

Message: 9 of 9


"Steve Amphlett" <Firstname.Lastname@Where-I-Work.com> wrote in message
news:hl0k9e$gso$1@fred.mathworks.com...
> "mat001 " <priya.biomath@gmail.com> wrote in message
> <hl0jks$61v$1@fred.mathworks.com>...
>> "Steve Amphlett" <Firstname.Lastname@Where-I-Work.com> wrote in message
>> <hkujc1$a4f$1@fred.mathworks.com>...
>> > "mat001 " <priya.biomath@gmail.com> wrote in message
>> > <hkuef1$i8m$1@fred.mathworks.com>...
>> > > "Saravanan Mani" <saravanan.ms55@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.
>> >
>> > Not strictly true. It's not a layer OVER the m-files. They're history
>> > and cannot be reconstructed.
>>
>> what do u mean by history here?
>> can you explain little more.
>
> I mean that the donor m-file cannot be reconstructed or extracted. It's a
> one-way trip.

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

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

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us