Introduction to MATLAB & SIMULINK: A Project Approach, Third Edition

1.6: MATLAB PROGRAMMING

1.6 MATLAB PROGRAMMING

As noted at the beginning of this chapter, MATLAB is not only a numerical program for evaluating formulas, but is a programming language in itself. This means that, besides the commands mentioned previously, MATLAB includes such program language constructs as loops and branches and provides for the writing of functions and procedures.

These capabilities are discussed in this section.

1.6.1 MATLAB Procedures

The first step in programming is to provide script files, in which MATLAB command sequences are collected into simple procedures.

This involves writing the MATLAB command sequences with a text editorthat can be opened, e.g., with the menu entry File - new - m-file in the MATLAB workspace (see Section 1.7), into a file and then saving this file under a name (e.g., proceed.m) or as a so-called m- file in a path accessible to MATLAB. (It might be a good idea to check the execution of the path command in Section 1.2.6 again.)

The sequence of commands can then be executed in the command window with the command proced. In order to avoid problems, whenever possible you must not use any previously employed command name. You can check whether such a command name already exists by, for example, just typing help in the command window. An even more reliable method is to use the function exist. If the call exist returns a value of 0, then no function with that name exists in...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Robot Software
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.