In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
What is the P code file in Matlab? I believe many inexperienced people don't know what to do about it. Therefore, this article summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
P code file in Matlab
We often write statements or functions in an M file, such as:
%--
% test.m
A = 1
B = 2
%--
This M statement file, or:
%--
% test2.m
Function a = test2 (b)
A = b * 2
%--
This M function.
We type in the Command Window:
> > test
Which is equal to the input.
> > a = 1
> > b = 2
And enter:
> > a = test2 (2)
A =
four
Is to execute a function.
I think most of you know what's going on. Let's talk about the P code file.
If you type in Command Window:
> > pcode test
The test.p is generated in the folder of the corresponding test.m. If you type in the Command Window at this time:
> > test
Test.p is actually running instead of test.m.
P file is a pre-parsed version of M file (preparsed version). Because when you execute the M file for the first time, Matlab needs to parse (parse) it once (the parsed content after the first execution will be put into memory for the second execution, that is, there is no need to parse the second execution), which virtually increases the execution time. So we explain in advance so that when we use the M file later, the corresponding parsed version, the P file, will be executed directly. However, because the parsing speed of Matlab is very fast, you generally don't have to do your own pre-parsing. It is only when some programs want to call a very large number of M files, such as GUI applications, that they do pre-parsing to increase the speed of future calls.
For example, the current directory (Current Directory) of Matlab has test.m files, and after pre-parsing, there are test.p files. Because the P file has a higher call priority than the M file, when you call test, you make a priority and call test.p.
The code for test.m can be modified as follows:
%--
% test.m
A = 3
B = 4
%--
Then call test in Command Window:
> > test
Warning: P-file C:/Program Files/MATLAB71/work/test.p is older than M-file C:/Program Files/MATLAB71/work/test.m.
C:/Program Files/MATLAB71/work/test.p may be obsolete and may need to be regenerated.
Type "help pcode" for information about generating P-files from M-files.
A Warning will appear warning you that the P file you called is older than the M file with the same name, indicating that the M file has been modified. Nevertheless, the old P file is called, that is, a = 1 and b = 2.
P file can be used as secret code. If you give someone an M file, they can open it to see all your code and algorithms. If your code does not want to be seen by others, you can give him the P file.
The pcode function can also be applied to the M function file.
After reading the above, have you mastered what the P code file in Matlab is? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.