MATLAB Release Notes |
|
Editing and Debugging M-Files
If you are using the Help browser, view the Editor new features video demo to see highlights of the major new features.
See the complete M-File Editing and Debugging documentation online.
Opening, Arranging, and Closing Documents
- You can drag a file onto Editor to open it. For example, drag a text file from Windows Explorer onto the Editor.
- There is now an Editor/Debugger preference you can set to automatically remove autosave files when you close the source file. Select Preferences -> Editor/Debugger -> Autosave, and under Close options, select the Automatically delete autosave files check box.
- To move from an Editor document to the Command Window, press Ctrl+0. To move back to the Editor document, press Ctrl+Shift+0.
- When you close the last open document in the Editor, the Editor remains open.
- When a file is open in the Editor and you open that same file outside of MATLAB and make changes to it, the Editor automatically updates the file to includes the changes you made outside the Editor. This only applies if you did not make any changes to the file in the Editor. If you want to be prompted before the Editor updates the file, clear the Editor/Debugger preference for automatically reloading files.
- In the previous version, you used a preference to automatically open files when debugging. Now, instead of using a preference, you select Open M-Files When Debugging from the Debug menu in any desktop tool.
Visual Changes
- The Editor now supports syntax highlighting for other languages, specifically C/C++, Java, and HTML. Use Editor language preferences to change the colors for the syntax highlighting.
- In edit mode, datatips are now off by default. Select the preference to display them in edit mode. Datatips display until you move the cursor. Datatips are always on in debug mode.
- There is now a faint line at column 75, which serves as a useful reminder of where text would be cut off when printing the document. Remove the line or change the column at which the line appears using Editor/Debugger Display preferences.
- The feature Text -> Balance Delimiters has been removed.
- The default colors for syntax highlighting M-files have been modified. Unterminated strings are now maroon, while terminated strings are now purple. This is the opposite of previous versions. Maroon is considered to be more of an "alerting" color, resembling the default of red for errors, which is the reason for the change. If you prefer the colors used in previous versions, change them using preferences--see Syntax Highlighting Colors in the online documentation.
In addition, arguments in statements entered using command syntax rather than function syntax are highlighted as strings, emphasizing that variables in command syntax are passed as literal strings rather than as their values.
Entering Statements
- You can create a block comment in an M-file using any text editor, that is, you can comment out contiguous lines of code. Type
%{
on the line before the first line of the comment and %}
following the last line of the comment. The lines in between are considered to be comments. Do not include any code on the lines with the block comment symbols. You can also nest block comments. See "Commenting Using Any Text Editor" for details.
- To change the case of selected text, select the text and then press:
- Alt+U, U to change all text to upper case
- Press Alt+U, L to change all text to lower case
- Press Alt+U, R to change the case of each letter
- MATLAB now supports nested functions and the Editor provides preferences regarding how to indent them.
- When you press the Insert key, text entry is done in overwrite mode and the cursor assumes a block shape. Press the Insert key again to return to insert mode.
Finding and Replacing Text
- You can find directories, files, and content within multiple files. Select Edit -> Find Files. For details, see Finding Files and Content Within Files in the online documentation.
- The incremental search interface has been updated. It now indicates the search direction. It is also case-sensitive when you enter uppercase letters in the search field.
Printing M-Files
Page setup options differ slightly from previous versions.
Breakpoints and Debugging
- You can specify conditional breakpoints in an M-file. MATLAB only stops at the line with the breakpoint if the condition is met. Conditional breakpoints have a yellow breakpoint icon, which you can copy and paste to other lines.
- You can disable standard and conditional breakpoints. MATLAB ignores a disabled breakpoint until you enable it again. A disabled breakpoint icon has an
X
through it.
- Set error breakpoints for all files by selecting Debug -> Stop If Errors/Warnings, and then completing the resulting dialog box. You can specify a message identifier for an error or warning breakpoint so that MATLAB stops only if it encounters the specified error or warning message.
- Enhancements to debugging functions include
dbstop if caught error
, dbclear if caught error
, and dbclear if all error
. The dbstop if all error
option has been grandfathered and will not be supported in future versions. To specify a message identifier, use dbstop if error ID
, dbstop if caught error ID
, dbstop if warning ID
, and the corresponding dbclear
options. The dbstatus
function has been updated to reflect the changes to dbstop
and dbclear
.
- The
dbstop
function has been updated to support nested and anonymous functions. See the dbstop
reference page for details.
You cannot use the Editor/Debugger GUI to set breakpoints in anonymous functions, but must use the dbstop
function instead. Note that when you save a file in the Editor/Debugger that contains breakpoints in anonymous functions, those breakpoints are cleared. They are also cleared when you run an unsaved file from the Editor/Debugger GUI, because running first saves the file.
- The
dbstack
function has been updated to supported nested functions. See the dbstack
function reference page and the Editing and Debugging upgrade issues for more information.
- The
dbstatus
function has been updated to support conditional breakpoints. See the dbstatus
function reference page and the Editing and Debugging upgrade issues for more information.
- You can access useful tools for M-files from the Editor/Debugger. From the Tools menu, select Check Code with M-Lint, Show Dependency Report, or Open Profiler. For details about these tools, see Tuning and Managing M-Files.
- MATLAB now uses a new notation for reporting the path of functions, subfunctions, and nested functions. As an example,
A/B>C/D
means directory A
, file B
, (sub)function C
within the file B
, and nested function D
within C
.
Rapid Code Iteration Using Cells
If you are using the Help browser, watch the new Rapid Code Iteration Using Cells video demo for an overview of the major functionality.
In the Editor, cell features allow you to easily make changes to values in a section of an M-file to readily see the impact of the changes. First, you define cells in a file, then evaluate a cell or cells, iterate values in the cell, and then reevaluate the cell(s). Cells also allow you to publish M-file code and results to popular formats, such as HTML and Microsoft Word. For details, see Rapid Code Iteration Using Cells in the online documentation.
Preferences for the Editor/Debugger
- There is now a preference that allows you to add a new line to end of a file upon saving.
- The feature that instructs M-files to open automatically when debugging is no longer in preferences but is now accessible from the Debug menu in all desktop tools.
| Workspace, Search Path, and File Operations | | Tuning and Managing M-Files | |
© 1994-2005 The MathWorks, Inc.