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.

4<br />

M-File <strong>Programming</strong><br />

When you write a program in <strong>MATLAB</strong>, you save it to a file called an M-file<br />

(named after its .m file extension). There are two types of M-files that you can<br />

write: scripts and functions. Most of this chapter is about functions, as they<br />

are the more complex and useful of the two M-file types.<br />

This chapter covers basic program development, describes how to write and<br />

call scripts and functions, and shows how to pass different types of data in a<br />

function call.<br />

Program Development (p. 4-3)<br />

Working with M-Files (p. 4-8)<br />

M-File Scripts and Functions<br />

(p. 4-18)<br />

Function Handles (p. 4-23)<br />

Procedures and tools used in<br />

creating, debugging, optimizing, and<br />

checking in a program<br />

Introduction to the basic <strong>MATLAB</strong><br />

program file<br />

Overview of scripts, simple programs<br />

that require no input or output, and<br />

functions, more complex programs<br />

that exchange input and output data<br />

with the caller<br />

Packaging the access to a function<br />

into a function handle, and passing<br />

that handle to other functions

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

Saved successfully!

Ooh no, something went wrong!