In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "basic programming skills of Matlab". In daily operation, I believe many people have doubts about the basic programming skills of Matlab. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "basic programming skills of Matlab". Next, please follow the editor to study!
Basic programming skills
Script m file and function m file, script is a simple combination of a series of commands and statements. The variables in the script file are global variables. After the program is run, these variables are saved in the basic workspace of matlab. Generally, the function clear is used to clear these variables.
In the process of execution of the function m file, the variables generated are generally local variables, stored in their own function space workspace, and will not conflict with the variables in the basic workspace. To the user, the m file is a black box with only input and output. Using m-file, it is very easy to realize the modularization of the program, and it can realize the division of work and cooperation of the program, and it is suitable for large-scale program development.
Type * .m displays the source program of the program in the command window
Help * .m prints help information for the function
1. Parameter transfer of function
Number of input parameters for nargin
Number of nargout output parameters
two。 Variable
Global variables are declared using global
Permanent variables can only be defined in the function M file: persistent variable
3.try...catch capture error
4. Human-computer interaction function
Users can enter data or strings from the keyboard and suspend the operation of the program
Input ():
Keyboard
Pause: continue to run the program by the mouse
Echo on: displays the program statements that will be run
Return: terminates the running of the program
5.p Code File and ASV File
In matlab files, you can convert M files to P code files. The P code file can be executed directly, which is faster than the M file. In addition, a temporarily saved ASV file is generated during the programming process of matlab.
The p code file is a version of the corresponding M file whose source code is not visible but can be executed. The suffix of P code file is * .p, and the function pcode () is used to generate the P code file of script M file or function M file. When the M file is executed for the first time, matlab needs to parse it once (the parsed content after the first execution will be put into memory for use in the second execution, that is, there is no need to parse the second execution), which increases the execution time of the program.
After the P-code file is generated, if the M file is called again, the P-code file will be executed directly. The parsing speed of matlab is very fast, and generally there is no need to generate P-code files. 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.
The asv file is used for the next recovery when the source program exits abnormally.
At this point, the study of "basic programming skills of Matlab" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.