Académique Documents
Professionnel Documents
Culture Documents
2011
MATLAB
Ing. Paul Glvez F.
Grafico en 2 y 3 dimensiones
Escuela de Ingeniera Sede Valparaso
GRFICOS 2D
1. COORDENADAS CARTESIANAS
plot( X , Y, prop)
X : vector con los valores de las abscisas Y : vector con los valores de las ordenadas (X , Y deben ser del mismo tamao). prop : opciones de graficacin
EJEMPLO 1
P.G.F. 2011
P.G.F. 2011
COMANDOS PARA MANEJO DE FIGURAS COMANDO Grid on,grid off axis([xmin xmax ymin ymax]) xlabel(etiqueta del eje x) ylabel (etiqueta del eje y) tittle (titulo de la grafica) text(X,Y,texto) ESPECIFICACIN Agrega retcula o la quita. Determina el mximo y el mnimo de los ejes. Etiqueta al eje x Etiqueta al eje x Coloca titulo a la grafica Coloca un texto en las coordenadas (X,Y)
P.G.F. 2011
EJEMPLO 2.
t = linspace(0,20,100); V = 10*sin(2*pi*t); plot(t,V) grid on; xlabel(tiempo (ms)'); ylabel (Voltaje (V)'); title('FUENTE DE CORRIENTE ALTERNA'); pause; grid on;
P.G.F. 2011
figure; subplot ( N filas , N columnas, posicin1) Plot(X1, Y1) subplot ( N filas , N columnas, posicin2) Plot(X2,Y2) ...
3.3. AGREGAR UNA CURVA A UNA GRAFICA YA TRAZADA
EJEMPLO 3. t = linspace(0,3*pi,1000); V = cos(2*pi*0.1*t).*sin(2*pi*2*t); plot(t,V,'r') hold on; V1 = cos(2*pi*0.1*t); V2 = -cos(2*pi*0.1*t); plot(t,[V1;V2],'b-.') hold off; title('SEAL MODULADA') text(6,0.8,'coseno envolvente')
P.G.F. 2011
semilogx( X , Y)
semilogy( X , Y)
t = linspace(0,10,1000); Y = exp(t); subplot(2,2,1) plot(t,Y) subplot(2,2,2) loglog(t,Y) subplot(2,2,3) semilogy(t,Y) subplot(2,2,4) semilogx(t,Y)
P.G.F. 2011
7
4. GRAFICA DE FUNCIONES IMPLICITAS fplot ( funcion, [xmin xmax ymin ymax] ) fplot ( funcion, [xmin xmax], paso )
EJEMPLO 5.
f ='[tan(x),sin(x),cos(x)]'; g ='sin(1 ./ x)'; subplot(2,1,1), fplot(f,2*pi*[-1 1 -1 1]) subplot(2,1,2), fplot(g, [0.01 0.1],1e-3)
VER EZPLOT
P.G.F. 2011
8
VER EZPOLAR
P.G.F. 2011
GRAFICAS 3D
x11 ... x1m X = M O M xn1 ... xnm y11 ... y1m Y = M O M yn1 ... ynm z11 ... z1m Z = M O M z n1 ... z nm
P.G.F. 2011
10
GRAFICAS 3D
GENERACIN DEL DOMINIO Y RANGO
COORDENADAS CARTESIANAS COORDENADAS ESFERICAS
Theta = th1 : dth : th2; Phi = ph1 : dph : ph2; [Theta , Phi] = meshgrid(Theta,Phi); r = f(Theta,Phi); [X,Y,Z]=sph2cart(r,Theta,Phi)
Theta = th1 : dth : th2; R = ph1 : dph : ph2; [R,Thetai] = meshgrid(R,Theta); Z = f(R,Theta); [X,Y,Z]=pol2cart(Theta,R,Z)
COMANDOS DE GRAFICACIN 3D PLOT3 (X,Y,Z) MESH (X,Y,Z) SURF (X,Y,Z) SURFL (X,Y,Z) GRAFICACIN SIMBOLICA EZPLOT3 (x(t),y(t),z(t)) EZMESH (Z) EZSURFL (Z) P.G.F. 2011
11
EJEMPLO 7a.
xa = -2:.2:2; ya = xa; [X Y] = meshgrid(xa,ya); Z = X.*exp(- X.^2 - Y.^2 ); plot3(X,Y,Z) xlabel('X'), ylabel('Y'), zlabel('Z')
P.G.F. 2011
12
EJEMPLO 7b.
xa = -2:.2:2; ya = xa; [X Y] = meshgrid(xa,ya); Z = X.*exp(- X.^2 - Y.^2 ); mesh(X,Y,Z) xlabel('X'), ylabel('Y'), zlabel('Z')
P.G.F. 2011
13
EJEMPLO 7c.
xa = -2:.2:2; ya = xa; [X Y] = meshgrid(xa,ya); Z = X.*exp(- X.^2 - Y.^2 ); surf(X,Y,Z) xlabel('X'), ylabel('Y'), zlabel('Z')
P.G.F. 2011
14
EJEMPLO 7d.
P.G.F. 2011
15
GRAFICAS DE CONTORNOS
EZCONTOUR(Z) EZCONTOURF(Z)
16
GRAFICAS 3D
EJEMPLO 8a.
17
GRAFICAS 3D
EJEMPLO 8b.
18