%%,在matlab代码中的作用是将代码分块,在运行代码的时候可以分块运行,查看每一块代码的运行情况。多用于调试程序。
使用案例:
选中某一块代码
然后点击 run section
就实现了分块的代码运行了
另外在有时候需要逐步向别人展示代码运行的结果,用%%分块以后拆开运行,也是很好的选择。
没什么特殊的用途,就是把文件分成几个部分,这样的话便于查看和调试。这样可以只运行一部分,你可以查看一下下面的这段帮助文件。
#
In the MATLAB Editor, select Cell > Enable Cell Mode. Items in the Cell menu become selectable. The cell toolbar appears, unless you had previously hidden it. With cell mode enabled, hide or show the toolbar by right-clicking in the Editor menu bar or toolbars and selecting Cell Toolbar from the context menu.
#
Define the boundaries of the cells in an M-file script using cell features. Cells are denoted by a specialized comment syntax, %%. For details, see Defining Cells.
#
After you define the cells, use cell features to navigate quickly from cell to cell in your file, evaluate the code in a cell in the base workspace, and view the results. To facilitate experimentation, use cell features to modify values in cells, and then reevaluate them to see how different values impact the result. For details, see Evaluating M-File Cells.