What is the difference between MATLAB code and P-code in MATLAB?

40 visualizaciones (últimos 30 días)
I would like to know the difference between MATLAB code and P-code in MATLAB.

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 27 de Jun. de 2009
When you call a MATLAB function from the command line or from within another MATLAB file, MATLAB parses the function and stores it in memory. The parsed function remains in memory until cleared with the CLEAR command or you quit MATLAB. The PCODE command performs the parsing step and stores the result on the disk as a P-file to be loaded later.
For example:
pcode average
This command parses average.m and saves the resulting pseudocode to the file named average.p. This saves MATLAB from reparsing average.m the first time you call it in each session.
MATLAB is very fast at parsing, so the PCODE function rarely makes much of a speed difference. One situation where P-code does provide a speed benefit is for large GUI applications. In this case, many MATLAB files must be parsed before the application becomes visible.
Another situation for P-code is when, for proprietary reasons, you want to hide algorithms you have created in your MATLAB file.
For more information, refer to the documentation on PCODE:
doc pcode
  1 comentario
Philip Borghesani
Philip Borghesani el 19 de Jun. de 2017
When in doubt ask Wikipedia: Parsing The sections on computer science and parsing explain it quite well. At one time MATLAB was implemented as a p-code interpreter see Wiki on P-code machine. The command name dates back to that time.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Programming en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by