23.06.2015 Views

MATLAB Programming

MATLAB Programming

MATLAB Programming

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Program Development<br />

Program Development<br />

This section explains the basic steps in developing an M-file program in<br />

<strong>MATLAB</strong>. Associated with each step in this process are certain <strong>MATLAB</strong> tools<br />

and utilities that are fully documented in the Desktop Tools and Development<br />

Environment documentation.<br />

This section covers<br />

• “Creating a Program” on page 4-3<br />

• “Getting the Bugs Out” on page 4-4<br />

• “Cleaning Up the Program” on page 4-5<br />

• “Improving Performance” on page 4-6<br />

• “Checking It In” on page 4-7<br />

For more ideas on good programming style, see “Program Development”<br />

on page 12-19 in the <strong>MATLAB</strong> <strong>Programming</strong> Tips documentation. The<br />

<strong>Programming</strong> Tips section is a compilation of useful pieces of information that<br />

can show you alternate and often more efficient ways to accomplish common<br />

programming tasks while also expanding your knowledge of <strong>MATLAB</strong>.<br />

Creating a Program<br />

You can type in your program code using any text editor. This section focuses<br />

on using the <strong>MATLAB</strong> Editor/Debugger for this purpose. The Editor/Debugger<br />

is fully documented in Ways to Edit and Debug Files in the Desktop Tools and<br />

Development Environment documentation.<br />

The first step in creating a program is to open an editing window. To create a<br />

new M-file, type the word edit at the <strong>MATLAB</strong> command prompt. To edit an<br />

existing M-file, type edit followed by the filename:<br />

edit drawPlot.m<br />

<strong>MATLAB</strong> opens a new window for entering your program code. As you type in<br />

your program, <strong>MATLAB</strong> keeps track of the line numbers in the left column.<br />

4-3

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!