用%%得到实现
- MATLAB code files often contain many commands and lines of text.MATLAB代码文件通常包含许多命令和文本行。
- You typically focus your efforts on a single part of your code at a time, working with the code and related text in pieces.您通常一次只关注代码的单个部分,将代码和相关文本分成几部分进行处理。
- For easier document management and navigation, divide your file into sections.为了更方便的文档管理和导航,可以将文件分成几个部分。
- Then, you can run the code in an individual section and navigate between sections, as needed.然后,您可以在单独的部分中运行代码,并根据需要在部分之间导航。
- Divide Your File into Sections把你的文件分成几个部分
- To create a section, go to the Editor or Live Editor tab and in the Section section, click the Section Break button.要创建一个区段,请转到“编辑器”或“实时编辑器”选项卡,并在“区段”区段中,单击“区段中断”按钮。
- You also can enter two percent signs (%%) at the start of the line where you want to begin the new section.您还可以在希望开始新部分的行开始处输入两个百分比符号(%%)。
- The new section is highlighted with a blue border, indicating that it is selected.新部分用蓝色边框突出显示,表明它已被选中。
- If there is only one section in your code file, the section is not highlighted, as it is always selected.如果代码文件中只有一个部分,则该部分不会突出显示,因为它总是被选中的。
- In the Editor, a section begins with two percent signs (%%).在Editor中,部分以两个百分比符号(%%)开始。
- The text on the same line as %% is called the section title.与%%在同一行的文本称为节标题。
- Including section titles is optional, however, it improves the readability of the file and appears as a heading if you publish your code.包含章节标题是可选的,但是,它提高了文件的可读性,并且在发布代码时显示为标题。

布局小经验:
matlab编辑器和主窗口分离了,如何恢复原来的布局:
首先,在编辑器窗口下,按ctrl+shift+D,此时编辑器窗口和主窗口就合并在一起了。
然后,在菜单栏中选择 布局-默认。这样就恢复到原来的布局了。