Professional Documents
Culture Documents
2 x 2
f x , y= y e
PRESENTACIN
En cada diapositiva se exponen las instrucciones a realizar
en la ventana de comandos del Matlab para obtener una
superficie.
Al lado de estas instrucciones se muestra tambin el
resultado grfico obtenido.
No pretendo repetir lo que hay en la ayuda del Matlab,
sobre el uso de comandos y funciones. Sugiero que se
consulte la mencionada ayuda cuando sea necesario.
Adolfo Canahuire Condori
Un primer ejemplo
>>
>>
>>
>>
>>
La funcin z= y
[x,y]=meshgrid(-4:.25:4);
z=y.^3;
surf(x,y,z)
axis square
xlabel('Eje X'),ylabel('Eje Y'),zlabel('Eje Z')
La funcin
meshgrid,
determina el
dominio de la
funcin
Funcin surf
del Matlab
para graficar
una superficie
Para etiquetar
los ejes
La funciones
para graficar
superficies en
el Matlab son:
surf
mesh
surfl
ezsurf
etc.
Dos planos
>>
>>
>>
>>
>>
Leyenda
[x,y]=meshgrid(-2:.1:2);
surf(x,y,-x+y,'FaceColor','blue')
hold on
surf(x,y,2.*x+y-1,'FaceColor','red')
legend('Plano z=-x+y','Plano z=2x+y-1')
Hold on
es para realizar
una grfica
sobre otra
x yz=0
2x yz=1
[x,y]=meshgrid(-10:.5:10);
z=4-y.^2;w=4-x.^2;surf(x,y,z)
hold on
surf(x,y,w)
w=4 x
Hold on
es para realizar
una grfica
sobre otra
z=4 y
Funcin: z=sin x y
2
>>
>>
>>
>>
>>
[x,y]=meshgrid(-3*pi:.25:3*pi);
z=sin(sqrt(x.^2+y.^2));
surf(x,y,z)
axis([-3*pi 3*pi -3*pi 3*pi -2 2])
colormap bone
Con el colormap
bone se proporciona
una escala de grises
Subgrficos
Subplot
para crear
subventanas
en la ventana
de la figura
f x , y=xy e
x 2 y 2
>>
>>
>>
>>
>>
>>
>>
>>
>>
[x,y]=meshgrid(-3:.2:3);
z1=-x.*y.*exp(-x.^2-y.^2);
z2=x.^2.*y.^2.*exp(-x.^2-y.^2);
subplot(1,2,1)
surf(x,y,z1),axis vis3d
daspect([10 10 1])
subplot(1,2,2)
surf(x,y,z2),axis vis3d
daspect([10 10 1])
2 x 2 y 2
f x , y= x y e
[x,y]=meshgrid(-4:.1:4);
surfc(x,y,exp(-x.^2)+exp(-y.^2))
axis([-4 4 -4 4 -0.5 2])
view(60,-15),axis off
Una rotacin de 60
y una elevacin de
-15
z=e
Curvas de nivel
Estos valores se
obtienen con
clabel
El color de las
curvas de nivel
varian desde la
parte superior
(rojo) a las parte
inferior (azul)
>>
>>
>>
>>
>>
Nmero de curvas
de nivel
[x,y]=meshgrid(-2:.1:2);
z=exp(-x.^2-y.^2);
[C,h]=contour(x,y,z,7),axis square
clabel(C,h)
title('Curvas de nivel de z=e^{-x^2-y^2}','FontSize',14)
Superficie de revolucin
>>
>>
>>
>>
>>
>>
>>
t=0:.1:4;[x,y,z]=cylinder(sqrt(t));
subplot(1,2,1)
plot(t,sqrt(t))
axis square,title('Curva que genera la superficie')
subplot(1,2,2)
surf(x,y,z),axis vis3d
title('Superficie')
Cono truncado
>>
>>
>>
>>
>>
>>
t=0:.05:2;[x,y,z]=cylinder(2*(1-t./3));
subplot(1,2,1)
plot(t,2*(1-t./3)),axis([0 2 0 3])
axis square
subplot(1,2,2)
surf(x,y,z),axis vis3d
t=-2:.1:2;[x,y,z]=cylinder(sqrt(1+(t.^2)/4));
subplot(1,2,1)
plot(t,sqrt(1+(t.^2)/4)),axis([-2 2 0 3])
axis square
subplot(1,2,2)
surf(x,y,z),axis vis3d
2
x
2
y =1
4
Para no mezclar x, y, z de
la funcin cylinder, es que
se usa la variable t
t
f t = 1
4
Conos
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
t=0:.05:1;
[x,y,z]=cylinder(t);[X,Y,Z]=cylinder(2*t);
subplot(1,2,1)
plot(t,t,t,2*t),axis([0 1 0 3])
axis square
subplot(1,2,2)
surf(x,y,z,'FaceColor','blue')
hold on
surf(X,Y,Z,'FaceColor','green')
axis vis3d
Tetraedros
Adolfo Canahuire Condori
t=0:.1:2;[x,y,z]=cylinder(t,3);
subplot(1,2,1)
surf(x,y,-z),axis vis3d,axis off
title('Tetraedro','Fontsize',14)
subplot(1,2,2)
surf(x,y,z),axis vis3d,axis off
title('Tetraedro invertido','Fontsize',14)
En estos c
uat
se usa la f ro ejemplos
uncin ezs
ur f
Paraboloides
>>
>>
>>
>>
>>
>>
>>
>>
subplot(2,2,1)
ezsurf('x^2+y^2'),axis square
subplot(2,2,2)
ezsurf('x^2+y^2','circ'),axis square
subplot(2,2,3)
ezsurf('4-x^2-y^2'),axis square
subplot(2,2,4)
ezsurf('4-x^2-y^2','circ'),axis square
Toro
>>
>>
>>
>>
>>
>>
>>
>>
t=-1:.05:1;[x,y,z]=cylinder(3+sqrt(1-t.^2));
[x1,y1,z1]=cylinder(3-sqrt(1-t.^2));
subplot(2,1,1)
plot(t,3+sqrt(1-t.^2),t,3-sqrt(1-t.^2))
axis([-2 2 0 4.5]),grid, axis square
subplot(2,1,2)
surf(x,y,z)
hold on,surf(x1,y1,z1)
La rotacin de la
circunferencia
alrededor del eje X,
genera el toro.
Elipsoide
Ecuaciones paramtricas
x=a cos u sin v
y=b sin u sin v
z=c cos v
>>
>>
>>
>>
>>
>>
>>
>>
>>
u=linspace(0,2*pi,50);
v=linspace(0,pi,40);
[U,V]=meshgrid(u,v);
a=5;b=2;c=1;
X=a*cos(U).*sin(V);
Y=b*sin(U).*sin(V);
Z=c*cos(V);
mesh(X,Y,Z),axis image
xlabel('X'),ylabel('Y'),zlabel('Z')
Dominio
0u2
0v
Ecuacin
cartesiana
x2 y 2 z2
2 2 =1
2
a b c
x
y
z
=1
2
2
2
5 2 1
Hemisferios
Ecuaciones paramtricas
x=2 cos v cos u
y=2 cos v sin u
z=2sin v
Dominio
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
u=linspace(0,2*pi,50);
v=linspace(0,pi/2,40);
[U,V]=meshgrid(u,v);
a=2;
X=a*cos(V).*cos(U);
Y=a*cos(V).*sin(U);
Z=a*sin(V);
subplot(1,2,1)
mesh(X,Y,Z,'EdgeColor','red')
axis equal
subplot(1,2,2)
mesh(X,Y,-Z,'EdgeColor','red')
axis equal
0u2
0v/2