Académique Documents
Professionnel Documents
Culture Documents
Universidad Te
mica de Ingeniera Civil
Unidad Acade
n MATLAB
Programacio
Reporte No. 1
GRAFICACION EN MATLAB
Autores:
Joel KelvinPaccha Alegria
Profesor:
Ing. Eduardo Tusa M.Sc.
11 de septiembre de 2016
Resumen
Esta practica presenta diferentes comandos para la generacion de graficas 2D en matlab
en diferentes sistemas referenciales cartesianos o polares, haciendo uso de funciones o
curvas paramaetricas. Estos ejercicios se basan en el Documento Graficas en MATLAB
elaborado por Roberto Rodriguez de la Universidad Complutense de Madrid.
1.
Ejercicios de Graficaci
on 2D
1.1.
x(x2)
1. f(x)= (x+1)(x+2)
1
2
3
x = 1:0.01:20;
y = (x.*(x-2))./((x+1).*(x+2));
plot(x,y);
2) f(x)=sen(1=x)
1
2
3
4
5
x= -1:0.01:1;
y= sin(1./x);
figure(2);
plot(x,y,'r');
grid on;
x
3. f(x)= e|x11|
1
2
3
4
5
x= -1:0.01:1;
y=x./exp(aba(x-1));
figure(3);
plot(x,y,'g');
grid on;
4.
1
2
3
4
t= -pi:0.01:pi;
x= (exp(t/4)).*sin(2*t);
y= (exp(t/4)).*cos(2*t);
plot(x,y);
5.
1
2
3
4
t= -pi:0.01:pi;
x= t - (10/11*sin(3*t));
y= - 22/10*cos(3*t);
plot(x,y);
1.2.
Curvas Parametricas
t= -pi:0.01:pi;
x= 2*(cos(t).3);
y= 2*(sin(t).3);
plot(x,y);
t= -pi:0.01:pi;
2
3
4
x= (3/2)*cos(t).*(cos(t)+1);
y= 2*(sin(2*t));
plot(x,y);
t= -pi:0.01:pi;
x= sin(2*t) + sin(t);
y= -cos(2*t) - cos(t);
plot(x,y);
1
2
3
4
t= -pi:0.01:pi;
x= (exp(t/4)).*sin(2*t);
y= (exp(t/4)).*cos(2*t);
plot(x,y);
5. ~r(t) = (t
1
2
3
4
11
sen(3t), 22
cos(3t)),
10
10
t= -pi:0.01:pi;
x= t - (10/11*sin(3*t));
y= - 22/10*cos(3*t);
plot(x,y);
1.3.
Coordenadas Polares
1. r = 7 7sen(),
1
2
3
tetha = -pi:0.01:pi;
r = 7 - 7*sin(tetha);
polar(tetha,r);
2. r = 3 6sen(),
1
2
3
tetha = -pi:0.01:pi;
r = 3 - 6*sin(tetha);
polar(tetha,r);
3. r = sen(6),
1
2
3
tetha = -pi:0.01:pi;
r = sin(6*tetha);
polar(tetha,r);
4. r = cos(8),
1
2
3
tetha = -pi:0.01:pi;
r = cos(8*tetha);
polar(tetha,r);
5. r =
5cos(2),
8
1
2
3
tetha = -pi:0.01:pi;
r = (5*cos(2*tetha)).0.5;
polar(tetha,r);
2.
Ejercicios de Graficaci
on en 3D
2.1.
Curvas en el espacio
t=-4:0.1:3;
plot3(2*cos(t).3, 2*sin(t).3,t);
grid on;
t= -pi:0.1:pi;
plot3(cos(t),cos(t).3,(1/4)*sin(t));
grid on;
t=-12:0.1:19;
plot3((t/6).*cos(t),(t/6).*sin(t),t/36);
grid on;
10
t= -10:0.1:4.8;
plot3(exp(t/4).*sin(2*t),exp(t/4).*cos(2*t),t/4),
grid on;
11
t= -9:0.1:10;
plot3(sin(2*t) + sin(t),-cos(2*t) -cos(t),(t/6));
grid on
3.
2
3
Por cada curva del ejercicio anterior, utilice el comando quiver3 para generar algunos vectores de velocidad de la curvas. Utilice la resolucion adecuada. Recuerde que el comandoquiver3
posee la siguiente sintaxis.
t=linspace(-4,3,150);
x=2*cos(t).3;
y=2*sin(t).3;
z=2*sin(t).3;
z=t;
u=-6*sin(t).*cos(t).2;
v=-6*cos(t).*sin(t).2;
w=1*ones(1,150);
quiver3(x,y,z,u,v,w);
12
t=linspace(-pi,pi,50);
x=cos(t);
y= cos(t).3;
z=(1/4)*sin(t);
u=-sin(t);
v=-3*sin(t).*cos(t).2;
w=(1/4)*cos(t);
quiver3(x,y,z,u,v,w);
13
t=linspace(-12,9,250);
x=(t/6).*cos(t);
y=(t/6).*sin(t);
z= t/3;
u=(cos(t)-t.*sin(t))/6;
v=(sin(t).*t.*cos(t))/6;
w=(1/36)*ones(1,250);
quiver3(x,y,z,u,v,w);
t=linspace(-10,4.8,100);
x= exp(t/4).*sin(2*t);
y=exp(t/4).*cos(2*t);
z=t/4;
u=exp(t/4).*2.*cos(2*t);
v= exp(t/4).*(-2.*sin(2*t));
w=-t/16.*ones(1,100);
quiver3(x,y,z,u,v,w);
14
t=linspace(-9,10,200);
x= sin(2*t)+sin(t);
y=-cos(2*t)- cos(t);
z=t/6;
u=2.*cos(2*t)+ cos(t);
v= 2.*sin(2*t)+ sin (t);
w=-t/36.*ones(1,200);
quiver3(x,y,z,u,v,w);
15
4.
Por cada curva que se presenta a continuacion, utilice los comandos plot3, mesh, surf y
surf con shading flat para hacer una representacion de las cuatro graficas en una sola ventanaa
traves del comando subplot.
1. z = 9+x12 +y2
1
2
3
4
5
6
7
8
xr= -2:0.05:2;
yr= -2:0.05:2;
[x,y]= meshgrid(xr,yr);
z= 1./(9+x.2+y.2);
subplot(2,2,1),plot3(x,y,z),title('plot3');
subplot(2,2,2),mesh(x,y,z),title('mesh');
subplot(2,2,3),surf(x,y,z),title('surf');
subplot(2,2,4),surf(x,y,z),shading flat, title('shading flat');
p
2. z = |xy|
1
2
3
4
5
6
7
8
xr= -2:0.05:2;
yr= -2:0.05:2;
[x,y]= meshgrid(xr,yr);
z= -((x.*y).0.5);
subplot(2,2,1),plot3(x,y,z),title('plot3');
subplot(2,2,2),mesh(x,y,z),title('mesh');
subplot(2,2,3),surf(x,y,z),title('surf');
subplot(2,2,4),surf(x,y,z),shading flat, title('shading flat');
16
3. z =
1
2
3
4
5
6
7
8
xr= -2:0.05:2;
yr= -2:0.05:2;
[x,y]= meshgrid(xr,yr);
z= (cos((x.2+y.2)./4))./(3+x.2+y.2);
subplot(2,2,1),plot3(x,y,z),title('plot3');
subplot(2,2,2),mesh(x,y,z),title('mesh');
subplot(2,2,3),surf(x,y,z),title('surf');
subplot(2,2,4),surf(x,y,z),shading flat, title('shading flat');
4. z =
1
2
3
4
5
cos( x +y
)
4
3+x2 +y 2
y2
5
3|x|
xr= -2:0.05:2;
yr= -2:0.05:2;
[x,y]= meshgrid(xr,yr);
z= ((y.2)/5)-3. * | x | ;
subplot(2,2,1),plot3(x,y,z),title('plot3');
17
6
7
8
subplot(2,2,2),mesh(x,y,z),title('mesh');
subplot(2,2,3),surf(x,y,z),title('surf');
subplot(2,2,4),surf(x,y,z),shading flat, title('shading flat');
5. ex2+y
1
2
3
4
5
6
7
8
xr= -2:0.05:2;
yr= -2:0.05:2;
[x,y]= meshgrid(xr,yr);
z= exp(-(x.2+y.2));
subplot(2,2,1),plot3(x,y,z),title('plot3');
subplot(2,2,2),mesh(x,y,z),title('mesh');
subplot(2,2,3),surf(x,y,z),title('surf');
subplot(2,2,4),surf(x,y,z),shading flat, title('shading flat');
18
5.
Contornos de la Forma
Utilice los comandos contour, contour3 y pcolor para obtener la reprsentacion de curvas de
nivel de los ejercicios de la seccion anterior. Las tres graficas resultantes deben aparecer en una
sola ventana simultaneamente.
1. z = 9+x12 +y2
1
2
3
4
5
6
[x,y]=meshgrid(-1:0.1:1);
z=1./(9+x.2+y.2);
subplot(2,2,1),contour(x,y,z,10),title('contour');
subplot(2,2,2),contour3(x,y,z,10),title('contour3');
subplot(2,2,[3 4]),pcolor(x,y,z),colorbar,title('pcolor');
19
p
2. z = |xy|
1
2
3
4
5
6
[x,y]=meshgrid(0:0.1:1);
z=-((x.*y).0.5);
subplot(2,2,1),contour(x,y,z,10),title('contour');
subplot(2,2,2),contour3(x,y,z,10),title('contour3');
subplot(2,2,[3 4]),pcolor(x,y,z),colorbar,title('pcolor');
3. z =
cos( x +y
)
4
3+x2 +y 2
1
2
3
[x,y]=meshgrid(-1:0.1:1);
z=(cos((x.2+y.2)./4))./(3+x.2+y.2);
20
4
5
6
subplot(2,2,1),contour(x,y,z,10),title('contour');
subplot(2,2,2),contour3(x,y,z,10),title('contour3');
subplot(2,2,[3 4]),pcolor(x,y,z),colorbar,title('pcolor');
4. z =
y2
5
3|x|
1
2
3
4
5
6
[x,y]=meshgrid(0:0.1:1);
z=((y.2)/5)-3.*x;
subplot(2,2,1),contour(x,y,z,10),title('contour');
subplot(2,2,2),contour3(x,y,z,10),title('contour3');
subplot(2,2,[3 4]),pcolor(x,y,z),colorbar,title('pcolor');
21
5. ex2+y
1
2
3
4
5
6
6.
[x,y]=meshgrid(-1:0.1:1);
z=exp(-(x.2+y.2));
subplot(2,2,1),contour(x,y,z,10),title('contour');
subplot(2,2,2),contour3(x,y,z,10),title('contour3');
subplot(2,2,[3 4]),pcolor(x,y,z),colorbar,title('pcolor');
Conclusiones
La conclusion es que con las graficas qu nos vota matlab nos ayuda a visualizar y entender
omo esa grafica toma sus valores y que esto nos ayudara en nuestro area de estudio y en la vida
ppractica, es muy complejo pero no dificil de aprender.
22