Está en la página 1de 7

Como graficar en Matlab

####################################################################################

Ejemplo ilustrativo integrador:

Tengo los siguientes datos: Medida de ida Ic [A] Va [V] 0,133 197,4 0,144 210,8 0,154 222,9 0,167 239,5 0,184 259,5 0,242 316 0,28 344 0,344 389 0,409 424 Medida de vuelta Ic [A] Va [V] 0,409 424 0,352 400,5 0,297 371,9 0,25 342 0,212 312 0,193 296 0,176 279,8 0,158 262,2 0,142 244,2 0,131 231,2

Cambio los puntos por comas y separo con comas usando Notepad++ con Ctrl+H (trabajo todo en Excel) Medida de ida Ic [A] Va [V] 0.133, 197.4, 0.144, 210.8, 0.154, 222.9, 0.167, 239.5, 0.184, 259.5, 0.242, 316 0.28, 344 0.344, 389 0.409 424 X1 Y1 Medida de vuelta Ic [A] Va [V] 0.409, 424 0.352, 400.5, 0.297, 371.9, 0.25, 342 0.212, 312 0.193, 296 0.176, 279.8, 0.158, 262.2, 0.142, 244.2, 0.131 231.2 X2 Y2

Ingreso ambos pares de vectores X1-Y1 y X2-Y2 en la ventana de comandos

Ingreso mi vector de datos X1 como: X1=[0.133, 0.144, 0.154, 0.167, 0.184, 0.242, 0.28, 0.344, 0.409 ] Luego sigo la siguiente sucesin de instrucciones (detalladas mas adelante) plot(X1,Y1,'k-',X1,Y1,'o',X2,Y2,'k--',X2,Y2,'*','Color','red','linewidth',2) axis([0.131,0.41,195,425]) xlabel('Corriente de Campo Ic [A]', 'FontSize',18) ylabel('Voltaje (fem) generada en la armadura E [V]', 'FontSize',17) title('Fem generada en Armadura en funcin de Corriente de Excitacin (w=1545[rpm])','FontSize',14) grid on legend(' ','Medicin aumentando sucesivamente Ic',' ','Medicin disminuyendo sucesivamente Ic') Lo obtienes como imagen en Export, en formato JPEG Y obtengo mi imagen:

#################################################################################### Ideas variadas sueltas: Ingreso mi vector de datos del eje x como: X=[1.243, 22, 300, 4000, 55000 ,670000] Ingreso mi vector de datos del eje y como Y=[1.23, 4.34, 5.67, 6, 30, 250] Luego para graficar ambos datos hago: plot(X,Y)

Luego, si quiero graficar el eje x como logartmico, hago: semilogx(X,Y)

Ambos logartmicos Loglog(X,Y) Y si le quiero aadir una grilla, hago: grid on

Y si quiero que el eje Y este en decibeles, hago:


Ydb = 20*log10(Y) Y luego hago:

semilogx(X,Ydb)

Y le aado una grilla con grid on

semilogx(X,Ydb,'k-','linewidth',3) plot(X,Y,'k-','linewidth',2) 2 graficas juntas con distintos estilos pero igual eje X: plot(X,Y,'k--',X,YA,'k-','Color','red','linewidth',2) loglog(X,Y,'k-','linewidth',3) activar grilla grid on Estilos de graficar lneas y colores
y m c r g yellow magenta cyan red green . o x + point circle x-mark plus solid

b w k

blue white black

* : -.

star dotted dashdot -dashed

Nombres a los ejes y titulo


xlabel('Voltaje de Control [V]', 'FontSize',16) ylabel('Tensin continua en la carga [V]', 'FontSize',16) title('Tensin en la carga en funcin del Voltaje de control','FontSize',18) xlabel('Resistencia Ro[k\Omega]', 'FontSize',16) ylabel('Frecuencia Libre [Hz] \itfo', 'FontSize',16)

Limites de los ejes:


axis([xmin,xmax,ymin,ymax])

Pa aadir leyenda a los graficados, en orden respectivo


legend('sin(x)','sin(x-.25)','sin(x-.5)')

Minimizacion en Matlab con restricciones http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/brg0p3g-1.html


Add a plot title, axis labels, and annotations: x = -pi:.1:pi; y = sin(x); p = plot(x,y) set(gca,'XTick',-pi:pi/2:pi) set(gca,'XTickLabel',{'-pi','-pi/2','0','pi/2','pi'}) xlabel('-\pi \leq \Theta \leq \pi') ylabel('sin(\Theta)') title('Plot of sin(\Theta)') % \Theta appears as a Greek symbol (see String) % Annotate the point (-pi/4, sin(-pi/4)) text(-pi/4,sin(-pi/4),'\leftarrow sin(-\pi\div4)',... 'HorizontalAlignment','left') % Change the line color to red and % set the line width to 2 points set(p,'Color','red','LineWidth',2)

Colores lnea:

Aumento el grosor del trazo del grafico con: set(findobj(gca,'Type','line','Color',[1 1 1]),'Color',[0,0,0],'LineWidth',100) Color del fondo:
whitebg('w') whitebg('white') whitebg([1 1 1]);

Mas de una function en el mismo grafico


x = 0:pi/100:2*pi; y = sin(x); y2 = sin(x-.25); y3 = sin(x-.5); plot(x,y,x,y2,x,y3)
The legend command provides an easy way to identify the individual plots:

legend('sin(x)','sin(x-.25)','sin(x-.5)')

Y con varios estilos de lnea en el mismo grafico:


http://www.engin.umich.edu/group/ctm/extras/plot.html

Elevar un vector a una potencia


x = -1:.1:1; % Define the range of x y = x.^3; % Raise each element in x to the third power

Caja de herramientas pa graficar


plottools

Y le pongo nombre al eje x y al y:

xlabel('x = 0:2\pi') ylabel('Sine of x') title('Plot of the Sine Function','FontSize',12)

For example, these statements plot three related functions of x, with each curve in a separate distinguishing color:

x = 0:pi/100:2*pi; y = sin(x); y2 = sin(x-.25); y3 = sin(x-.5); plot(x,y,x,y2,x,y3)

# grafico x desde 0 hasta 2phi con 100 puntos entremedio

The legend command provides an easy way to identify the individual plots:

legend('sin(x)','sin(x-.25)','sin(x-.5)') Pagina de comandos Matlab pa graficar:

http://www.mathworks.com/access/helpdesk/help/techdoc/learn_matlab/f3-27853.html

axis([-pi pi -1 1]) xlabel('-\pi \leq {\itt} \leq \pi') ylabel('sin(t)') title('Graph of the sine function') text(1,-1/3,'{\itNote the odd symmetry.}')

http://www.engin.umich.edu/group/ctm/extras/plot.html Graficar con lnea negra semilogx(X,Ydb,'k-') Con lnea punteada semilogx(X,Ydb,'k--')

También podría gustarte