Escolar Documentos
Profissional Documentos
Cultura Documentos
INTRODUCCIN
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.
1
Prof. ISIDRO REYNALDO MUNAYA SANCHEZ FACULTAD DE INGENIERIA MECANICA
+ : Adicin ejemplo: 3 + 2
- : Sustraccin ejemplo: 9 5
* : Multiplicacin ejemplo: 5 * 7
/ : Divisin ejemplo: 5 / 9
\ : Divisin inversa 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)
2
Prof. ISIDRO REYNALDO MUNAYA SANCHEZ FACULTAD DE INGENIERIA MECANICA
FUNCIN SIGNIFICADO
exp( u ) Funcin exponencial y eu
log( u ) Funcin logaritmo natural (base e) y ln(u)
log10( u ) Funcin logaritmo en base 10 y log (u)
log2( u ) Funcin logaritmo en base 2 y log 2 (u)
sqrt( u ) Funcin raz cuadrada y u
abs( u ) Funcin valor absoluto y u
sign( u ) Funcin signo y sig (u)
3
Prof. ISIDRO REYNALDO MUNAYA SANCHEZ FACULTAD DE INGENIERIA MECANICA
>> >>
2x x 1
2
3x
03. y 04. y arccos arctgh(2 x 2 )
x 2 3x 2
>> >>
05. y x3e82x 06. y arctgh (2 x 2 )
2
>> >>
2x x2 x
07. y 08. y
1 x2 1 x2
>> >>
09. y x sen (1/ x)
2
10. y
ln( x)
4x
>>
>>
11. y x3 4 x 12. y x e x
2
>> >>
x 2
13. y 14. y
1 x e e x
x
>> >>
1 2x
15. y 16. y
3
3x 1 x 1
2
>> >>
x3 1 x
17. y 18. y
6 2x x2 9
>> >>
3
x 1 x3 1
19. y 20. y
6 2x 6 2x
>> >>
4
Prof. ISIDRO REYNALDO MUNAYA SANCHEZ FACULTAD DE INGENIERIA MECANICA
2
SESIN 02: GRFICO DE FUNCIONES REALES DE VARIABLE REAL EN :
SINTAXIS
>> x=-20:0.001:20;
>> y=3*x-x.^2;
>> plot(x,y)
>> grid
02. y x 2 1 4
>> x=-2:0.001:2;
>> y=abs(x.^2-1)+4;
>> plot(x,y)
>> grid
3 8 2x2
03. y x e
>> x=-2.5:0.001:2.5;
>> y=(x.^3).*exp(8-2*x.^2);
>> plot(x,y)
>> grid
5
Prof. ISIDRO REYNALDO MUNAYA SANCHEZ FACULTAD DE INGENIERIA MECANICA
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
a) plot (x, y, * ); grafica los puntos con estrellas (*) sin estar conectados por lneas.
Existen cinco opciones en este tipo:
1) . punto 2) + ms 3) * asterisco 4) o circunferencia 5) x equis
b) plot (x, y, *r ); grafica los puntos con estrellas (*) de color rojo. Existen ocho
opciones en este tipo:
1) r rojo 2) y amarillo 3) g verde 4) b azul
5) w blanco 6) m magenta 7) c turquesa 8) k negro
>> x=-pi:0.001:pi;
>> y=atan(2*x.^2);
>> plot(x,y,'+g')
>> grid
>> x=-4:0.005:4;
>> y=abs(x.^3-4*x);
>> plot(x,y,'*r')
>> grid
>> x=-pi:0.05:pi;
>> y=tan(x);
>> plot(x,y,'b')
>> grid
7
Prof. ISIDRO REYNALDO MUNAYA SANCHEZ FACULTAD DE INGENIERIA MECANICA
GRFICO DE FUNCIONES POR TRAMOS: Para esto tener presente los siguientes
comentarios
2 ; x 1
Ejemplo 01: Hacer el grfico para la siguiente funcin f (x) x 1; 1 x 1
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')
8
Prof. ISIDRO REYNALDO MUNAYA SANCHEZ FACULTAD DE INGENIERIA MECANICA
x 3 ; x 1
Ejemplo 03: Hacer el grfico para la siguiente funcin f (x) 4 x 2 ; 1 x 1
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
>> >>
>> >>
>> >>
9
Prof. ISIDRO REYNALDO MUNAYA SANCHEZ FACULTAD DE INGENIERIA MECANICA
>> >>
>> >>
>> >>
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
>> >>
>> >>
>> >>
>> >>
>> >>
>> >>
13. y x3 4 x 2 14. y x 2 2 x 2
>> >>
>> >>
>> >>
>> >>
>> >>
>> >>
10
Prof. ISIDRO REYNALDO MUNAYA SANCHEZ FACULTAD DE INGENIERIA MECANICA
>> >>
>> >>
>> >>
x 2x
2
; x
3; 1 x 3 ; si x 6;0
19. f (x)
20. f (x) 2(x 1) 2 ;si x 0; 2
2 3 2x x ; x 1;1
2
2 x 4 ; si x 2;10
>>
>>
>>
>>
>>
>>
x 2 10x 21; x 5; 1
x 2 ;si x 2;6
22. f (x)
21. f (x) x 2 1
x 2x 3; si x 1;1
2
x 3 ; x 1; 2
>> >>
>> >>
>> >>
11
Prof. ISIDRO REYNALDO MUNAYA SANCHEZ FACULTAD DE INGENIERIA MECANICA
>> x=-3:0.001:3;
>> y=3-x.^2;
>> z=-x+1;
>> plot(x,y,x,z)
>> grid
ln( x)
02. y ; 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
Prof. ISIDRO REYNALDO MUNAYA SANCHEZ FACULTAD DE INGENIERIA MECANICA
1 x2
04. y ; 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
Prof. ISIDRO REYNALDO MUNAYA SANCHEZ FACULTAD DE INGENIERIA MECANICA
>> 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
Prof. ISIDRO REYNALDO MUNAYA SANCHEZ FACULTAD DE INGENIERIA MECANICA
>> x=
>> y=
>> z=
>> plot
>> grid
02. y x3 6 x ; y x3 4 x 2 ; x 2;4 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
x2 1 Grfico:
04. y 2 ; y 9 x 2 9; x 1.5;1.5
x 1/ 4
>> x=
>> y=
>> z=
>> plot
>> grid
15
Prof. ISIDRO REYNALDO MUNAYA SANCHEZ FACULTAD DE INGENIERIA MECANICA
3x 2 13x 4 2 x 2 4 x 10 Grfico:
05. y ; y
5 3
3x 12
y ; x 5;3
2
>> 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
>> x=
>> y=
>> z=
>> w=
>> plot
>> grid
16
Prof. ISIDRO REYNALDO MUNAYA SANCHEZ FACULTAD DE INGENIERIA MECANICA
El comando ezplot dibuja curvas como plot en cartesianas y paramtricas de una manera
ms sencilla ya que genera automticamente los valores de la variable independiente.
Tambin se utiliza para dibujar curvas en implcitas. Utiliza el intervalo 2 ; 2 por
defecto.
>> ezplot('cos(x)'),grid
>> ezplot('atan(x)'),grid
SINTAXIS
>> ezplot('') Dado la ecuacin f ( x, y) 0 , entonces grafica
la funcin f ( x, y) para un dominio por
defecto
>> ezplot('',[a b]) Dado la ecuacin f ( x, y) 0 , entonces grafica
la funcin f ( x, y) en el intervalo a ; b
>> ezplot('y^3+y^2+5*x*y+x^2+x+y')
>> grid
02. 4 y3 27 x 2
>> ezplot('-27*x^2+4*y^3')
>> grid
03. xy 1 0
>> ezplot('x*y-1')
>> grid
18
Prof. ISIDRO REYNALDO MUNAYA SANCHEZ FACULTAD DE INGENIERIA MECANICA
04. (2 x) y 2 (2 x) x2
>> ezplot('((2+x)*y^2)-((2-x)*x^2)')
>> grid
06. x2 sen( x y) 5 ye x 3 ; x 8 ; 8
19
Prof. ISIDRO REYNALDO MUNAYA SANCHEZ FACULTAD DE INGENIERIA MECANICA
Ejemplo 01: Graficar las siguientes funciones y sen ( x) ; y cos( x) ; 8;8 luego
agregar el grfico de la funcin y x 2 2
Solucin:
>> x = -8:0.05:8;
>> y = sin(x);
>> z = cos(x);
>> plot (x, y, x, z);
>> hold on
>> w = abs(x - 2) - 2;
>> plot (x, w, 'r');
>> grid
Ejemplo 02: Graficar las siguientes funciones y sen ( x) ; y cos( x) ; 0;5 Agregar
los Ejes de Coordenadas y ttulo al grfico anterior.
Solucin:
>> x = 0:0.05:5;
>> y = sin(x);
>> z = cos(x);
>> plot (x, y, x, z);
>> grid
>> xlabel ('Eje X');
>> ylabel ('Eje Y');
>> title ('Grfica con Matlab');
20
Prof. ISIDRO REYNALDO MUNAYA SANCHEZ FACULTAD DE INGENIERIA MECANICA
Ejemplo 03: Graficar en el mismo plano las funciones y sen ( x) , y cos( x) . Luego
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
01. x3 xy y3 0; x [2;2] Grfico:
21
Prof. ISIDRO REYNALDO MUNAYA SANCHEZ FACULTAD DE INGENIERIA MECANICA
04. e y x y Grfico:
y 1 Grfico:
05. arctg ln( x 2 y 2 ) ; x [4; 4]
x 2
22
Prof. ISIDRO REYNALDO MUNAYA SANCHEZ FACULTAD DE INGENIERIA MECANICA
x y Grfico:
06. y 3 ; x [10;8]
x y
23
Prof. ISIDRO REYNALDO MUNAYA SANCHEZ FACULTAD DE INGENIERIA MECANICA
SINTAXIS
>> ezplot('', ''); Grafica funciones vectoriales de la
forma f (t ) ( f1 (t ) ; f 2 (t )) con dominio
por defecto
>> ezplot('', '',[a b]); Grafica funciones de la forma
f (t ) ( f1 (t ) ; f 2 (t )) 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 3
f (t ) ( f1 (t ) ; f 2 (t ); f3 (t )) con dominio
por defecto y progresivamente
>> ezplot3('', '', '',[a b]); Dibuja la curva en 3
f (t ) ( f1 (t ) ; f 2 (t ); f3 (t )) en el
intervalo a ; b
>> ezplot3('', '', '',[a b], 'animate'); Dibuja la curva en 3
f (t ) ( f1 (t ) ; f 2 (t ); f3 (t ))
progresivamente en el intervalo a ; b
>>ezplot('exp(-t)*cos(2*pi*t)','exp(-
t)*sin(2*pi*t)');
>> grid
>> syms t;
>> y=exp(-t)*cos(2*pi*t);
>> z=exp(-t)*sin(2*pi*t);
>> ezplot(y,z);
>> grid
24
Prof. ISIDRO REYNALDO MUNAYA SANCHEZ FACULTAD DE INGENIERIA MECANICA
>> ezplot('2*cos(t)','2*sin(t)');
>> grid
>> ezplot('t*sin(t)','t*cos(t)');
>> grid
>> ezplot('exp(t)*cos(t)','exp(t)*sin(t)',[-pi
2*pi]);
>> grid
25
Prof. ISIDRO REYNALDO MUNAYA SANCHEZ FACULTAD DE INGENIERIA MECANICA
>> ezplot3('sin(t)','cos(t)','t');
>> ezplot3('t*cos(t)','t*sin(t)','t');
>> ezplot3('t*cos(t)','t*sin(t)','t','animate');
>> ezplot3('2*t','t^2','log(t)','animate');
26
Prof. ISIDRO REYNALDO MUNAYA SANCHEZ FACULTAD DE INGENIERIA MECANICA
>>
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 8],
'animate');
05. f (t ) (t ; t ; sen (t )) ; t 2 ; 4
>>ezplot3('t','t','sin(t)',[-2*pi 4*pi],'animate');
27
Prof. ISIDRO REYNALDO MUNAYA SANCHEZ FACULTAD DE INGENIERIA MECANICA
>> 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
Prof. ISIDRO REYNALDO MUNAYA SANCHEZ FACULTAD DE INGENIERIA MECANICA
>> 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