A Guide to MATLAB for Beginners and Experienced Users

Chapter 4: Beyond the Basics

In this chapter, we describe some of the finer points of MATLAB and review in more detail some of the concepts introduced in Chapter 2. We explore enough of MATLAB's internal structure to improve your ability to work with complicated functions, expressions, and commands. At the end of this chapter, we introduce some of the MATLAB commands for doing calculus.

Suppressing Output

Some MATLAB commands produce output that is superfluous. For example, when you assign a value to a variable, MATLAB echoes the value. You can suppress the output of a command by putting a semicolon after the command. Here is an example:

<b class="bold">>> syms x>>y = x + 7</b>y =x+7<b class="bold">>>z = x + 7;>> z</b>z =x+7

The semicolon does not affect the way MATLAB processes the command internally, as you can see from its response to the command z.

You can also use semicolons to separate a string of commands when you are interested only in the output of the final command (several examples appear later in the chapter). Commas can also be used to separate commands without suppressing output. If you use a semicolon after a graphics command, it will not suppress the graphic.

Note

The most common use of the semicolon is to suppress the printing of a long vector, as indicated in Chapter 2.

Another object that you may want to suppress is MATLAB's label for the output of a command. The command disp is designed to achieve that; typing disp(x)

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: SCR Power Controllers
Finish!
Privacy Policy

This is embarrasing...

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