Graphics Programs Reference
In-Depth Information
linspace
Anothermeansofcreating an array with equally spaced elements is the
linspace
function. The statement
x
= linspace(
xfirst
,
xlast
,
n
)
creates an array of
n
elements starting with
xfirst
and ending with
xlast
. Here is an
illustration:
>>x=linspace(0,1,5)
x=
0
0.2500
0.5000
0.7500
1.0000
logspace
The function
logspace
is the logarithmiccounterpartof
linspace
. The call
x
= logspace(
zfirst
,
zlast
,
n
)
10
z first
and ending with
creates
n
logarithmically spaced elements starting with
x
=
10
z last
. Here is an example:
x
=
>>x=logspace(0,1,5)
x=
1.0000
1.7783
3.1623
5.6234
10.0000
zeros
The function call
X
= zeros(
m
n
)
,
returns amatrix of
m
rows and
n
columnsthat is filledwith zeroes.When the fun-
ctioniscalledwith a single argument, e.g.,
zeros(
n
)
, a
n
×
n
matrix iscreated.
ones
X
= ones(
m
,
n
)
The function
ones
works in the manneras
zeros
, but fills the matrix with ones.
rand
X
= rand(
m
,
n
)
Thisfunctionreturns amatrix filledwith random numbers between 0 and 1.
Search WWH ::
Custom Search