| Contents | Index |
| On this page… |
|---|
Use the Editor to create and debug programs you write for running MATLAB functions. The Editor provides a graphical user interface for text editing and debugging MATLAB code.
To create or edit a file select File > New or File > Open, or use the edit function.
The following image shows the Editor with two documents, collatzall.m and collatz.m open. Notice the following:
Colors highlight various MATLAB language elements — blue for keywords, green for comments.
The code analysis message bar contains an orange box and bar, indicating there are areas for improvement in the code.
Other Editor features are described in the image.

You can use any text editor to create files, such as Emacs. Use Editor/Debugger preferences (accessible from the desktop by selecting File > Preferences > Editor/Debugger) to specify your default editor. If you use another editor, you still can use the MATLAB Editor for debugging, or you can use debugging functions, such as dbstop, which sets a breakpoint.
To view the contents of a file, you can display the contents in the Command Window using the type function.
Use code analysis to help you identify problems and potential improvements in your code. For details, see Improving and Tuning Your MATLAB Programs.
You can evaluate your code in sections (called code cells). Also, you can publish your code, including results, to popular output formats like HTML. For more information, see Evaluate Subsections of Files Using Code Cells in the MATLAB Desktop Tools and Development Environment documentation.
For More Information See Editing and Debugging MATLAB Code, the function reference pages for edit, type, and the list of Debugging Functions functions. |
Use code analysis to help you write correct and efficient MATLAB code. Code analysis:
Identifies areas for improvement by underlining code in orange
Identifies errors by underlining code in red
Provides short messages, called Code Analyzer messages, to describe all suspected trouble spots
Provides extended Code Analyzer messages for many suspected trouble spots
Provides automated fixes for many trouble spots
The following images show code with a message at line 22 and 23. The Details button in the first message indicates that an extended message is available for that first problem. To have MATLAB fix a problem for you, click the Fix button, if displayed.

When you click a Details button, the message extends and provides a detailed explanation, a suggested action, and sometimes links to the documentation.

For More Information See Avoid Mistakes While Editing Code. |
While or after you create a MATLAB code file, you can use the Editor's Cell > Insert Text Markup menu options to specify the formatting you want for publishing the file to various output types. For example, you might want to publish a file to present at a meeting, include in a blog, or share with colleagues.
Insert Text Markup options include options that enable you to do the following and more:
Create titles for the document and sections within it.
Specify the text format — bold, italic, monospaced, or hyperlinked
Insert an image
Format lists

After adding text markup, click the Publish button
on the Editor toolbar. By default, MATLAB software
generates formatted HTML output and presents the document in the MATLAB Web
Browser.

You can publish MATLAB code files to HTML, XML, LaTeX, and PDF. If your system is a personal computer (PC), you also can publish files to Microsoft Word and PowerPoint®.
For More Information See Publishing MATLAB Code in the MATLAB Desktop Tools and Development Environment documentation, and the publish reference page. |
![]() | Finding and Getting Files Created by Other Users — File Exchange | Improving and Tuning Your MATLAB Programs | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |