Métodos de Graficación en Matlab Lic. Gabriel Arcos.

19
Métodos de Métodos de Graficación en Graficación en Matlab Matlab Lic. Gabriel Arcos Lic. Gabriel Arcos

Transcript of Métodos de Graficación en Matlab Lic. Gabriel Arcos.

Page 1: Métodos de Graficación en Matlab Lic. Gabriel Arcos.

Métodos de Graficación Métodos de Graficación en Matlaben Matlab

Lic. Gabriel ArcosLic. Gabriel Arcos

Page 2: Métodos de Graficación en Matlab Lic. Gabriel Arcos.

Graficación. Pasos a seguir.Graficación. Pasos a seguir.

Preparar los datosPreparar los datos x = 0:0.2:12;x = 0:0.2:12;y1 = bessel(1,x);y1 = bessel(1,x);y2 = bessel(2,x);y2 = bessel(2,x);y3 = bessel(3,x);y3 = bessel(3,x);

Abrir ventana y Abrir ventana y configurarconfigurar

figure(1)figure(1)

Ejecutar comandoEjecutar comandográficográfico

h = plot(x,y1,x,y2,x,y3);h = plot(x,y1,x,y2,x,y3);

Cambiar propiedadesCambiar propiedadesdel objeto gráficodel objeto gráfico

set(h,'LineWidth',2)set(h,'LineWidth',2)

Page 3: Métodos de Graficación en Matlab Lic. Gabriel Arcos.

Graficación. Pasos a seguir.Graficación. Pasos a seguir.

Agregar etiquetas yAgregar etiquetas ytextotexto

xlabel('Time')xlabel('Time')ylabel('Amplitude')ylabel('Amplitude')legend(h,'First','Second','Third')legend(h,'First','Second','Third')title('Bessel Functions')title('Bessel Functions')[y,ix] = min(y1);[y,ix] = min(y1);text(x(ix),y,'First Min \rightarrow',... text(x(ix),y,'First Min \rightarrow',... 'HorizontalAlignment','right')'HorizontalAlignment','right')

Exportar el gráficoExportar el gráfico print -depsc -tiff -r200 myplotprint -depsc -tiff -r200 myplot

Cambiar las propiedadesCambiar las propiedadesdel eje de coordenadasdel eje de coordenadas

axis([0 12 -0.5 1])axis([0 12 -0.5 1])grid ongrid on

Page 4: Métodos de Graficación en Matlab Lic. Gabriel Arcos.

Graficación. Pasos a seguir.Graficación. Pasos a seguir.

x = 0:0.2:12;x = 0:0.2:12;y1 = bessel(1,x);y1 = bessel(1,x);y2 = bessel(2,x);y2 = bessel(2,x);y3 = bessel(3,x);y3 = bessel(3,x);

figure(1)figure(1)

h = plot(x,y1,x,y2,x,y3);h = plot(x,y1,x,y2,x,y3);

set(h,'LineWidth',2)set(h,'LineWidth',2)

axis([0 12 -0.5 1])axis([0 12 -0.5 1])grid ongrid on

xlabel('Time')xlabel('Time')ylabel('Amplitude')ylabel('Amplitude')legend(h,'First','Second','Third')legend(h,'First','Second','Third')title('Bessel Functions')title('Bessel Functions')[y,ix] = min(y1);[y,ix] = min(y1);text(x(ix),y,'First Min \rightarrow',... text(x(ix),y,'First Min \rightarrow',... 'HorizontalAlignment','right')'HorizontalAlignment','right')

Page 5: Métodos de Graficación en Matlab Lic. Gabriel Arcos.

Funciones de una variableFunciones de una variable

)(xfy Graficar:Graficar:

x = 0:0.05:2*pi;x = 0:0.05:2*pi;y = sin(x);y = sin(x);plot(x,y,’b-’)plot(x,y,’b-’)

Page 6: Métodos de Graficación en Matlab Lic. Gabriel Arcos.

Curvas ParamétricasCurvas Paramétricas

))(),((),( tvtuyx ))(),(),((),,( twtvtuzyx

Graficar las curvas:Graficar las curvas:

t=-100:.05:100;t=-100:.05:100;x=t;x=t;y=(2*t)./(1+t.^2);y=(2*t)./(1+t.^2);z=(1-t.^2)./(1+t.^2);z=(1-t.^2)./(1+t.^2);plot3(x,y,z,'b-')plot3(x,y,z,'b-')

Page 7: Métodos de Graficación en Matlab Lic. Gabriel Arcos.

Funciones de dos variablesFunciones de dos variables

),( yxfz Graficar:Graficar:

[X,Y] = meshgrid(-3:.125:3);Z = peaks(X,Y);mesh(X,Y,Z)

Page 8: Métodos de Graficación en Matlab Lic. Gabriel Arcos.

Funciones de dos variablesFunciones de dos variables

),( yxfz Graficar:Graficar:

[X,Y] = meshgrid(-3:.125:3);Z = peaks(X,Y);surf(X,Y,Z)

Page 9: Métodos de Graficación en Matlab Lic. Gabriel Arcos.

Curvas implícitasCurvas implícitas

cyxF ),(Graficar:Graficar:

[x,y] = meshgrid(-1.5:0.1:1.5);v =(x.^4)+(y.^4)+2*(x.^2).*(y.^2)-2*(x.^2)+2*(y.^2)+1;contour(x,y,v,[1 1])

Page 10: Métodos de Graficación en Matlab Lic. Gabriel Arcos.

Superficies implícitasSuperficies implícitas

czyxF ),,(Graficar:Graficar:

[x,y,z] = meshgrid(-1.5:0.1:1.5);v =x.^2+y.^2-z;patch(isosurface(x,y,v,[1 1]),…’FaceColor’,’blue’)

Page 11: Métodos de Graficación en Matlab Lic. Gabriel Arcos.

Configuración de la ventanaConfiguración de la ventana

f = figure;f = figure;

set(f,’Color’,’white’)set(f,’Color’,’white’)

set(f,’Renderer’,’OpenGL’)set(f,’Renderer’,’OpenGL’)

set(f,’DoubleBuffer’,’on’)set(f,’DoubleBuffer’,’on’)

set(f,’Renderer’,’painters’)set(f,’Renderer’,’painters’)set(f,’Renderer’,’zbuffer’)set(f,’Renderer’,’zbuffer’)

f = figure(’Color’,’white’…f = figure(’Color’,’white’…’’Renderer’,’OpenGL’…Renderer’,’OpenGL’…’’DoubleBuffer’,’on’);DoubleBuffer’,’on’);

Page 12: Métodos de Graficación en Matlab Lic. Gabriel Arcos.

Configuración del eje de Configuración del eje de coordenadascoordenadas

axis([0 1 0 1])axis([0 1 0 1])

set(gca,’Color’,’yellow’)set(gca,’Color’,’yellow’)

axis([0 1 0 1 0 1])axis([0 1 0 1 0 1])

grid ongrid on

Page 13: Métodos de Graficación en Matlab Lic. Gabriel Arcos.

Propiedades de objetos gráficosPropiedades de objetos gráficosLineLine

SurfaceSurface PatchPatch

Page 14: Métodos de Graficación en Matlab Lic. Gabriel Arcos.

Propiedades de objetos gráficosPropiedades de objetos gráficos

•Color•LineStyle: [ {-} | -- | : | -. | none ]•LineWidth•Marker: [ + | o | * | . | x | square | diamond | v | ^ | > | < |

pentagram | hexagram | {none} ]•MarkerSize•XData•YData•ZData

x=0:.05:2*pi;y=sin(x);h=plot(x,y);

set(h,’Propiedad’,valor)

set(h,'Color','black','LineWidth',3)

Page 15: Métodos de Graficación en Matlab Lic. Gabriel Arcos.

Propiedades de objetos gráficosPropiedades de objetos gráficos

•EdgeAlpha•EdgeColor•FaceAlpha•FaceColor•LineStyle: [ {-} | -- | : | -. | none ]•LineWidth•Marker: [ + | o | * | . | x | square | diamond | v | ^ | > | < | pentagram | hexagram | {none} ]•MarkerSize

SURFACE Y PATCH:

Page 16: Métodos de Graficación en Matlab Lic. Gabriel Arcos.

Propiedades de objetos gráficosPropiedades de objetos gráficos

set(h,'FaceColor','yellow','EdgeColor','black')

Page 17: Métodos de Graficación en Matlab Lic. Gabriel Arcos.

Definir el punto de vistaDefinir el punto de vista

view(30,30)view([1 1 1])

Page 18: Métodos de Graficación en Matlab Lic. Gabriel Arcos.

Agregar iluminaciónAgregar iluminación

[x,y,z]=meshgrid(-1.5:.1:1.5);

v=x.^2+y.^2-z;

h=patch(isosurface(x,y,z,v,1),…'FaceColor','blue','EdgeColor','none');

view([1 1 1])

lighting gouraud

light

Page 19: Métodos de Graficación en Matlab Lic. Gabriel Arcos.

Exportar el gráficoExportar el gráfico

Built-in MATLAB Drivers:

Formato Postscript: -dps, -dpsc, -dps2, -dpsc2.

Formato EPS: -deps, -depsc, -deps2, -depsc2

Otros Formatos:-djpeg<nn>, -dtiff, -dpng

print –deps2c –r300 myplot