MATLAB FINANCIAL DERIVATIVES TOOLBOX Manual de usuario Pagina 52

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 119
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 51
51
Third Section
3. Plots and Graphs (2D and 3D)
It is quite easy to create a plot or a graph by using the variables or
parameters that have already been stored in the Matlab’s workspace. Matlab
offers a variety of build-in functions for creating simple two dimensional
plots, 3 dimensional surface plots, to combine plots to a larger one and so
on. The following subsections are a very brief and an elementary reference to
the visualization capabilities of Matlab.
3.1 Creating 2D Line Plots
The basic function for the creation of a simple 2D line plot is called:
p
p
l
l
o
o
t
t. Let
be a row or column vector with real data named
Y
Y, with elements “y
1
, y
2
, …,
y
n”
. If
p
p
l
l
o
o
t
t is called as: “
p
p
l
l
o
o
t
t(Y)”, then a linear plot of the elements of
Y
Y versus
its index will appear (the
p
p
l
l
o
o
t
t function creates/plots the pairs: (1, y
1
), (2, y
2
),
…, (n, y
n
) and connects them with a line). If for each “y
i
” we have an
accompanied “x
j
” coordinate, then the function “
p
p
l
l
o
o
t
t(X,Y)” plots all pairs: (x
1
,
y
1
), (x
2
, y
2
), …, (x
n
, y
n
) and connects them with a line. Note that vectors
Y
Y
and
X
X must share the same length. Additionally, if the data to be plotted are
stored in a two dimensional array, then the arguments for the
p
p
l
l
o
o
t
t function
can be done via the use of colon notation “:”. It is very easy to plot the
following function in the range [0,5]:
5
152
3
2
+
=
x
xx
y
Matlab’s command:
>> clear; x=0:0.5:5; y=(2*x.^2+5*x-1)./(x.^3-5); plot(x,y);
>> x=0:0.2:5; ; y=(2*x.^2+5*x-1)./(x.^3-5); plot(x,y);
Vista de pagina 51
1 2 ... 47 48 49 50 51 52 53 54 55 56 57 ... 118 119

Comentarios a estos manuales

Sin comentarios