Skip to Main Content Skip to Search
Product Documentation

Editor

Editing MATLAB Code Files

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:

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.

Identifying Problems and Areas for Improvement

Use code analysis to help you write correct and efficient MATLAB code. Code analysis:

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.

Publishing MATLAB Code Files

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:

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®.

  


Recommended Products

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