Graphics Programs Reference
In-Depth Information
array, sometimes called a scalar .A1 × n array is called a row vector , and
an m × 1 array is called a column vector . (A string is actually a row vector of
characters.)An m × n arrayofnumbersiscalleda matrix ;see MoreonMatrices
below. You can see the class and array size of every variable you have defined
by looking in the Workspace browser or typing whos (see Managing Variables
in Chapter 2). The set of variable definitions shown by whos is called your
Workspace .
To use MATLAB commands effectively, you must pay close attention to the
class of data eachcommand accepts as input and returns as output. The input
to a command consists of one or more arguments separated by commas; some
arguments are optional. Some commands, suchas whos , do not require any
input. When you type a pair of words, such as hold on , MATLAB interprets
the second word as a string argument to the command given by the first word;
thus, hold on is equivalent to hold('on') . The help text (see OnlineHelp in
Chapter2)foreachcommandusuallytellswhatclassesofinputsthecommand
expects as well as what class of output it returns.
Many commands allow more than one class of input, though sometimes
only one data class is mentioned in the online help. This flexibility can be a
convenience in some cases and a pitfall in others. For example, the integration
command, int , accepts strings as well as symbolic input, though its help
text mentions only symbolic input. However, suppose that you have already
defined a=10 , b=5 , and now you attempt to factor the expression a 2
b 2 ,
forgetting your previous definitions and that you have to declare the variables
symbolic:
>> factor(aˆ2 - bˆ2)
ans =
3
5
5
The reason you don't get an error message is that factor is the name of
a command that factors integers into prime numbers as well as factoring
expressions. Since a 2
= 75 = 3 · 5 2 , the numerical version of factor is
applied. This output is clearly not what you intended, but in the course of a
complicated series of commands, you must be careful not to be fooled by such
unintended output.
b 2
Note that typing help factor only shows you the help text for the
numerical version of the command, but it does give a cross-reference to the
symbolic version at the bottom. If you want to see the help text for the
symbolic version instead, type help sym/factor . Functions suchas
factor withmore than one version are called overloaded .
Search WWH ::




Custom Search