Professional Documents
Culture Documents
FIEE - UNAC
INTRODUCCIN
MATLAB es el nombre abreviado de MATriz LABoratory. Es un programa para
realizar clculos numricos con vectores y matrices, y por tanto se puede trabajar
tambin con nmeros escalares (tanto reales como complejos), con cadenas de
caracteres y con otras estructuras de informacin ms complejas.
Matlab es un lenguaje de alto rendimiento para clculos tcnicos, es al mismo
tiempo un entorno y un lenguaje de programacin. Uno de sus puntos fuertes es que
permite construir nuestras propias herramientas reutilizables. Podemos crear fcilmente
nuestras propias funciones y programas especiales (conocidos como M - archivos) en
cdigo Matlab, los podemos agrupar en Toolbox (tambin llamadas libreras): coleccin
especializada de M - archivos para trabajar en clases particulares de problemas.
Matlab, a parte del clculo matricial y lgebra lineal, tambin puede manejar
polinomios, funciones, ecuaciones diferenciales ordinarias, diferentes tipos de grficos.
Tenemos la pantalla abierta para poder trabajar.
FIEE - UNAC
:
:
:
:
:
Adicin
Sustraccin
Multiplicacin
Divisin
Divisin inversa
ejemplo: 3 + 2
ejemplo: 9 5
ejemplo: 5 * 7
ejemplo: 5 / 9
ejemplo: 4 \ 5, divide 5 entre 4 (Alt + 92)
^
~=
>
<
>=
<=
&
|
==
[
]
:
:
:
:
:
:
:
:
:
:
:
:
Exponente
ejemplo: 6^2 = 6 2 (Alt + 94)
Diferente
ejemplo: 3 5 (para ~ hacer Alt + 126)
Mayor
Menor
Mayor o igual
Menor o igual
y operador lgico
o operador lgico (Alt + 124)
igual operador lgico
Abrir corchete (hacer Alt + 91)
Cerrar corchete (hacer Alt + 93)
Apstrofe (hacer Alt + 39)
Nombre de la variable
pi
Significado
I
inf
eps
2,22046 16 (Epsilon)
FIEE - UNAC
INVERSA
TRIGONOMTRICA
asin( u )
acos( u )
atan( u )
acot ( u )
asec( u )
acsc( u )
FUNCIONES
HIPERBLICAS
sinh( u )
cosh( u )
tanh( u )
coth ( u )
sech( u )
csch( u )
INVERSAS
HIPERBLICAS
asinh( u )
acosh( u )
atanh( u )
acoth ( u )
asech( u )
acsch( u )
SIGNIFICADO
Funcin exponencial y eu
Funcin logaritmo natural (base e) y ln(u)
log10( u )
log2( u )
sqrt( u )
abs( u )
sign( u )
y e x sen ( x)
>> y=x.^2-3*x;
>> y=exp(x).*sin(x);
y ln( x 1)
y x 4x
2
>> y=log(x-1);
y ln(1 x2 )
>> y=sqrt(4*x-2);
>> y=log(1-x.^2);
ex 1
y ln x
e 1
>> y=log((exp(x)+1)./(exp(x)-1));
x2 x
y
1 x2
>> y=(x.^2-x)./(1+x.^2);
y e x senh ( x)
y ( x 2 2 x) e x
>> y=exp(-x).*sinh(x);
>> y=(x.^2+2*x).*exp(x)
y e arcsenh ( x)
>> y=exp(2*x).*asinh(x);
x2 4
x2
>> y=(x.^2+4)./(x-2)
y x sen (1/ x)
y x3 e x
>> y=x.*sin(1./x);
>> y=(x.^3)+exp(x)
2x
FIEE - UNAC
02. y x 2 x
>>
>>
03. y
3x
04. y arccos arctgh(2 x 2 )
2
2x2 x 1
x 2 3x
>>
>>
05. y x e
06. y arctgh (2 x2 )
>>
>>
3 8 2x2
07. y
2x
08. y
1 x2
>>
x2 x
1 x2
>>
10. y
>>
ln( x)
4x
>>
11. y x 4 x
12. y x e x
>>
>>
13. y
x
1 x
14. y
2
e e x
x
>>
>>
15. y
1
3
3x 1
16. y
>>
>>
x3 1
17. y
6 2x
18. y
>>
>>
3
2x
x2 1
x
x2 9
x
1
19. y
6 2x
x3 1
20. y
6 2x
>>
>>
FIEE - UNAC
SINTAXIS
>> x=a:s:b;
>> y=..;
>> plot(x,y)
Grafica la funcin y f ( x)
>> grid
02. y x 2 1 4
>> x=-2:0.001:2;
>> y=abs(x.^2-1)+4;
>> plot(x,y)
>> grid
3 8 2x
03. y x e
>> x=-2.5:0.001:2.5;
>> y=(x.^3).*exp(8-2*x.^2);
>> plot(x,y)
>> grid
FIEE - UNAC
04. y arctg (2 x 2 )
>> x=-pi:0.001:pi;
>> y=atan(2*x.^2);
>> plot(x,y)
>> grid
ex 1
05. y ln x
e 1
>> x=0:0.005:1.5;
>> y=log((exp(x)+1)./(exp(x)-1));
>> plot(x,y)
>> grid
06. y x 2 x
>> x=-5:0.005:5;
>> y=sqrt(x.^2+abs(x));
>> plot(x,y)
>> grid
07. y x3 4 x
>> x=-4:0.005:4;
>> y=abs(x.^3-4*x);
>> plot(x,y)
>> grid
FIEE - UNAC
>> x=-pi:0.001:pi;
>> y=atan(2*x.^2);
>> plot(x,y,'+g')
>> grid
Ejemplo 01: Graficar la funcin de color
rojo
y x3 4 x
>> x=-4:0.005:4;
>> y=abs(x.^3-4*x);
>> plot(x,y,'*r')
>> grid
Ejemplo 01: Graficar la funcin de color
azul
y tan(2 x)
>> x=-pi:0.05:pi;
>> y=tan(x);
>> plot(x,y,'b')
>> grid
FIEE - UNAC
GRFICO DE FUNCIONES POR TRAMOS: Para esto tener presente los siguientes
comentarios
*) El comando linspace permite generar vectores con un nmero determinado de
elementos equi espaciados.
Ejemplo: genera el siguiente vector
>> linspace(0,1,5)
(genera el siguiente vector con 5 puntos)
ans =
0 0.2500 0.5000 0.7500 1.0000
2 ; x 1
Solucin:
>> x=linspace(-4,4,2000);
>> y=(-2).*(x<=-1)+(x-1).*((-1<x)&(x<1))+2.*(1<=x);
>> plot(x,y,'.'),grid on,title('FUNCIN DEFINIDA A TROZOS')
2x 2 1; 3 x 1
Ejemplo 02: Hacer el grfico para la siguiente funcin f (x)
2x 3 ;1 x 3
Solucin:
>> x=linspace(-3,3,1000);
>> y=((2*x.^2)-1).*((-3<=x)&(x<=1))+(2*x+3).*((1<=x)&(x<=3));
>> plot(x,y,'.'),grid on,title('FUNCIN DEFINIDA A TROZOS; DIME SI TE ENCANTA')
FIEE - UNAC
x 3 ; x 1
Solucin:
>> x=linspace(-3,4,1000);
>> y=(-x.^3).*(x<=-1)+(4-x.^2).*((-1<x)&(x<1))+(-3).*(1<=x);
>> plot(x,y,'.'),grid on,title('FUNCIN DEFINIDA A TROZOS; TE ENCANT')
ACTIVIDAD 01
Codificar correctamente y graficar las siguientes funciones e indicar el dominio
adecuado:
01. y x 2 4 x
02. y 2 x 4
>>
>>
>>
>>
>>
>>
03. y ln(2 x)
04. y 3x 2
>>
>>
>>
>>
>>
>>
FIEE - UNAC
06. y x3 3x 2 2 x
>>
>>
>>
>>
>>
>>
07. y 4 x 4 3x 2 2 x 5
08. y 2 x3 x 2 5x 6
>>
>>
>>
>>
>>
>>
09. y x 4 x 2
10. y 3x x 2
>>
>>
>>
>>
>>
>>
11. y ln( x 2 4)
12. y e x 2 x
>>
>>
>>
>>
>>
>>
13. y x3 4 x 2
14. y x 2 2 x 2
>>
>>
>>
>>
>>
>>
15. y ln( x 1) ; x 2; e2 1
16. y ln(1 x 2 ) ; x 1/ 4 ;3 / 4
>>
>>
>>
>>
>>
>>
10
FIEE - UNAC
tg(x)
;/4 x /4
x 2 x ; si x 4;0
2x 8 ; si x 4;10
>>
>>
>>
>>
>>
>>
x 2 2x
; x
3; 1
19. f (x)
2
2 3 2x x ; x 1;1
x 3
; si x 6;0
2 x 4 ; si x 2;10
>>
>>
>>
>>
>>
>>
x 2 10x 21; x 5; 1
21. f (x) x 2 1
; x 1; 2
x 3
x 2 ;si x 2;6
22. f (x)
2
x 2x 3; si x 1;1
>>
>>
>>
>>
>>
>>
11
FIEE - UNAC
02. y
ln( x)
; y x ln( x) ; x 0.4 ; 1.2
4x
>> x=0.4:0.001:1.2;
>> y=(log(x))./(4*x);
>> z=x.*log(x);
>> plot(x,y,x,z)
>> grid
03. y 4 x2 ; y 4 4 x ; x 1;5
>> x=-1:0.001:5;
>> y=4-x.^2;
>> z=4-4*x;
>> plot(x,y,x,z)
>> grid
12
FIEE - UNAC
1
x2
;
y
; x 2; 2
1 x2
2
>> x=-2:0.001:2;
>> y=1./(1+x.^2);
>> z=(x.^2)/2;
>> plot(x,y,x,z)
>> grid
05. y x3 3x ; y x ; x 3 ; 3
>> x=-3:0.001:3;
>> y=x.^3-3*x;
>> z=x;
>> plot(x,y,x,z)
>> grid
06. y 4 x2 ; y 4 4 x ; x 1;5
>> x=-1:0.001:5;
>> y=4-x.^2;
>> z=4-4*x;
>> plot(x,y,x,z)
>> grid
07. y x3 4 x 2 x 6 ; 3 y x 2 0
x 0;4
>> x=0:0.01:4;
>> y=abs((x.^3)-(4*x.^2)+x+6);
>> z=-(x.^2)/3;
>> plot(x,y,x,z)
>> grid
13
FIEE - UNAC
x 6;8
>> x=-6:0.001:8;
>> y=x.^2;
>> z=8-x.^2;
>> w=4*x+12;
>> plot(x,y,x,z,x,w)
>> grid
02. y x3 4 x ; y x ; y x
x 3;3
>> x=-3:0.001:3;
>> y=x.^3-4*x;
>> z=x;
>> w=-x;
>> plot(x,y,x,z,x,w)
>> grid
03. y x2 ; y 2 x 1 ; y 4 0
x 0.25 ; 2.75
>> x=0.25:0.001:2.75;
>> y=x.^2;
>> z=2*x-1;
>> w=4;
>> plot(x,y,x,z,x,w,'r')
>> grid
14
FIEE - UNAC
Grfico:
>> x=
>> y=
>> z=
>> plot
>> grid
03. y 30sen(2 x); y x(6 x)2 ; x 2;8
Grfico:
>> x=
>> y=
>> z=
>> plot
>> grid
04. y
x2 1
; y 9 x 2 9; x 1.5;1.5
2
x 1/ 4
Grfico:
>> x=
>> y=
>> z=
>> plot
>> grid
15
3x 2 13x 4
2 x 2 4 x 10
; y
5
3
3x 12
y
; x 5;3
2
05. y
FIEE - UNAC
Grfico:
>> x=
>> y=
>> z=
>> w=
>> plot
>> grid
06. y x3 12 x ; y x ; y x
Grfico:
x 5;5
>> x=
>> y=
>> z=
>> w=
>> plot
>> grid
07. y cos x ; y cos 2 x ; y cos 4 x
Grfico:
x 0 ; 2
>> x=
>> y=
>> z=
>> w=
>> plot
>> grid
16
FIEE - UNAC
>> ezplot('atan(x)'),grid
>> ezplot('')
FIEE - UNAC
SINTAXIS
Dado la ecuacin f ( x, y) 0 , entonces grafica
la funcin
defecto
Dado la ecuacin f ( x, y) 0 , entonces grafica
la funcin f ( x, y) en el intervalo a ; b
02. 4 y3 27 x 2
>> ezplot('-27*x^2+4*y^3')
>> grid
03. xy 1 0
>> ezplot('x*y-1')
>> grid
18
FIEE - UNAC
04. (2 x) y 2 (2 x) x 2
>> ezplot('((2+x)*y^2)-((2-x)*x^2)')
>> grid
06. x2 sen( x y) 5 ye x 3 ; x 8 ; 8
>> ezplot('(x^2*sin(x+y))-5*y*exp(x)-3',[-8 8])
>> grid
19
FIEE - UNAC
FIEE - UNAC
Ejemplo 03: Graficar en el mismo plano las funciones y sen ( x) , y cos( x) . Luego
agregar el grfico de la siguiente funcin x 2 y 2 16 , x 8 ; 8
Solucin:
>> x=-8:0.01:8;
>> y=cos(x);
>> z=sin(x);
>> plot(x,y,x,z)
>> hold on
>> ezplot('x^2+y^2-16')
>> grid
ACTIVIDAD 02
Codificar y graficar las siguientes funciones dadas implcitamente
Grfico:
01. x3 xy y3 0; x [2;2]
02. 2 x2 xy y 2 8 0; x [4;4]
Grfico:
21
FIEE - UNAC
03. y 2 5x xe x ( y 2) ; x [8;8]
Grfico:
04. e y x y
Grfico:
y 1
05. arctg ln( x 2 y 2 ) ; x [4; 4]
x 2
Grfico:
22
06. y 3
x y
; x [10;8]
x y
FIEE - UNAC
Grfico:
Grfico:
x [ 4;4]
Grfico:
23
FIEE - UNAC
de
f (t ) ( f1 (t ) ; f 2 (t ))
la
forma
en el intervalo
a ; b
>> ezplot3('', '', '');
Grafica
funciones
de
la
forma
f (t ) ( f1 (t ) ; f 2 (t ); f3 (t )) con dominio
por defecto
>> ezplot3('', '', '', 'animate');
Dibuja la curva en
f (t ) ( f1 (t ) ; f 2 (t ); f3 (t )) con dominio
por defecto y progresivamente
>> ezplot3('', '', '',*a b+);
Dibuja la curva en
f (t ) ( f1 (t ) ; f 2 (t ); f3 (t ))
en
el
intervalo a ; b
>> ezplot3('', '', '',*a b+, 'animate');
Dibuja la curva en
f (t ) ( f1 (t ) ; f 2 (t ); f3 (t ))
progresivamente en el intervalo a ; b
EJEMPLOS:
Graficar
las
siguientes
funciones
f (t ) ( f1 (t ) ; f 2 (t ))
01. f (t ) (et cos(2 t ); et sen (2 t ))
>>ezplot('exp(-t)*cos(2*pi*t)','exp(t)*sin(2*pi*t)');
>> grid
Nota: Tambin se puede escribir
>> syms t;
>> y=exp(-t)*cos(2*pi*t);
>> z=exp(-t)*sin(2*pi*t);
>> ezplot(y,z);
>> grid
24
vectoriales
de
la
forma
FIEE - UNAC
>>
ezplot('exp(t)*cos(t)','exp(t)*sin(t)',[-pi
2*pi]);
>> grid
25
Graficar
las
FIEE - UNAC
siguientes
funciones
f (t ) ( f1 (t ) ; f 2 (t ) ; f3 (t ))
01. f (t ) ( sen (t );cos (t ); t )
>> ezplot3('sin(t)','cos(t)','t');
26
vectoriales
de
la
forma
FIEE - UNAC
>>
ezplot3('exp(t)*cos(t)','exp(t)*sin(t)','t*exp(t)
',[-pi 4*pi],'animate');
04. f (t ) (1 2t ; t 2 ; 2e(2t 2) )
t 2;8
>>ezplot3('1-2*t','t^2','2*exp(2*t-2)',[-2
'animate');
8],
05. f (t ) (t ; t ; sen (t )) ; t 2 ; 4
>>ezplot3('t','t','sin(t)',[-2*pi 4*pi],'animate');
27
FIEE - UNAC
>> t = 0:0.01:2*pi;
>> r = abs (sin(2*t).*cos(2*t));
>> polar (t,r);
02. r 2 2 sen (t )
>> t = -2*pi:0.01:2*pi;
>> r=2-2*sin(t);
>> polar (t,r);
03. r 2cos (5 t )
>> t=-2*pi:0.01:2*pi;
>> r=2*cos(5*t);
>> polar (t,r);
28
FIEE - UNAC
>> t = -2*pi:0.01:2*pi;
>> r = 2*sin(3*t);
>> polar (t,r);
>> t = -2*pi:0.01:2*pi;
>> r=2-2*sin(t);
>> polar (t,r);
t
06. r 1 2 sen
2
>> t=-2*pi:0.01:2*pi;
>> r=1+2*sin(t/2);
>> polar (t,r);
29