Está en la página 1de 11

---> -2a+b+c

2x-y+z=3

x+y=3

y-3z=7

----------------

###PARA MATRICES ENCONTRARLAS###

>> A = [3 -1 0; -2 1 1; 2 -1 4]

A=

3 -1 0

-2 1 1

2 -1 4

>> b= [5;0;15]

b=

15

>> n = length(b)

n=

3
>> d = det(A) %determinante de A

d= det(A); %determinante de A

>> x= zeros(n,1); %matriz cero de una columna

>> for i=1:n

Ab= [A(:,1:i-1),b,A(:,i+1:n)];

x(i)=det(Ab)/d;

end

>> disp('solution')

solution

>> disp(x);

2.0000

1.0000

3.0000

----------------------------

###GRFICAS###

fplot('sin(x^2)',[0 10])

<<<Da resultado, poniendo una grfica>>>

>> x = [-4 -2 0 1 3 5];

>> y = [16 4 0 1 9 25];

>> plot(x,y)

>> z = [1 2+i 3 2-i 3-2*i];

>> plot (z)

<<<Da resultado, poniendo una grfica>>>

###COMO PONER FUNC###


Normal: f= sen(4x)

En Matlab: f= sin(4*x) plot(x,f,'--b')

###OTRA MANERA PARA GRAFICAR 3 EN UNA SOLA GRFICA CON COLORES Y


ESPECIFICACIONES##

>> x = linspace(0,3,50);

>> e1 = exp(-x.^2);

>> e2 = (x.^2).*exp(-x.^2);

>> e3 = x.*(exp(-x.^2));

>> e4 = exp(-x);

>> plot(x,e1,'+-r',x,e2,'+-b',x,e3,'+-g',x,e4,'+-y')

###OTRA MANERA PARA GRAFICAR VARIAS EN DIFERENTES GRAFICAS###

>> x = linspace(0,3,50);

>> e1 = exp(-x.^2);

>> e2 = (x.^2).*exp(-x.^2);

>> e3 = x.*(exp(-x.^2));

>> e3 = x.*(exp(-x.^2));

>> e4 = exp(-x);

>> subplot(2,2,1); -------------------> NOTA: (A,B,C) A=Columna | B=Fila | C=Funciones, num que te
dan

>> plot(x,e1);

>> subplot(2,2,2);

>> plot(x,e2);

>> subplot(2,2,3);

>> plot(x,e3);

>> subplot(2,2,4)

>> plot(x,e4);
####GRAFICA PARA FIGURAS CON NOMBRE###

>> t = 0:0.2:2*pi+0.2;

x=sin(t);

y=cos(t);

>> subplot(3,1,1);

plot(x,y,'-');

>> subplot(3,1,2);

plot(x,y,'-');

axis square;

>> subplot(3,1,3);

plot(x,y,'-');

axis normal; grid;

>> axis([-2 2 -3 3]);

>> title('Grafica De Circulos')

<<<SALE EL RESULTADO DE LA GRFICA CON SU NOMBRE>>>

--------------------------------------------------------

###PARA GUARDAR EN MATLAB###

Save as<seleccin de la carpeta<darle RUN<enter<Run and advance.

-------------------------------------------------------

###PARA VER EL PROCESADOR###

w = 0:00001:100000

-------------------------------------------------------
###Grficas 3D###

>> x = linspace(0,10*pi,1000);

>> y=cos(x);

>> z=sin(x);

>> plot3(x,y,z)

>> plot3(x,y,z,'r')

>> plot3(x,y,z,'r','linewidth',2)

>> grid;

>> title('Resorte :3')

>> xlabel('angulo')

>> ylabel('coseno(x)'); zlabel('sin(x)')

<<Sale la grfica>>

###Grficas Animadas###

>> clear all

>> t=[0:pi/50:10*pi];

>> comet3(sin(t),cos(t),t),hold on, figure (gcf),grid on

>> xlabel 'eje x'

>> ylabel 'eje y'

>> title('Resorte Animado >.<')

>> Hold off <----------------------------Para mantener una sola grfica, sin modificar.

<<Sale la grfica animada>>

###Grfica dimensional###
>> z=[1 2 3 4 5 6 7 8 9 10; 2 4 6 8 10 12 14 16 18 20; 3 4 5 6 7 8 9 10 11 12]

z=

1 2 3 4 5 6 7 8 9 10

2 4 6 8 10 12 14 16 18 20

3 4 5 6 7 8 9 10 11 12

>> mesh(z)

>> xlabel('eje x')

>> ylabel('eje y')

>> zlabel('eje z')

<<<Sale la grfica >>>

Para cambiar las dimenciones de la grfica, invierte:

>> x=linspace(1,50,10);

>> y=linspace(500,1000,3);

>> mesh(x,y,z)

###Grfica chida###

>> x=[-2:0.2:2];

>> y=[-2:0.2:2];

>> [X,Y]= meshgrid(x,y);

>> Z=X.*exp(-X.^2-Y.^2);

>> mesh(X, Y, Z),figure(gcf)

otro ejemplo:
>> x=[-2.1:0.15:2.1];

>> y=[-6:0.15:6];

>> [X,Y]= meshgrid(x,y);

>> Z = 80*Y.^2.*exp(-X.^2-0.3*Y.^2);

>> mesh(X,Y,Z)

otro ejem:

x= [-2:0.2:2];

>> y= [-2:0.2:2]; <--------- Mesh(muestra slo las lneas del graficado).

>> [X,Y]=meshgrid(x,y);

>> Z= X.*exp(-X.^2-Y.^2);

>> subplot(1,2,1)

>> mesh(X,Y,Z), title('Grafica Mesh :B'), xlabel('x'), ylabel('y'), xlabel('z');

otro ejemplo para ponerle relieve:

>> subplot(1,2,2)

>> surf(X,Y,Z), title('Grafica Mesh :B'), xlabel('x'), ylabel('y'), xlabel('z');

javier 19

fernando 27

pablo 26

otro ejemplo con efecto:

>> subplot(1,2,1);

>> surf(X,Y,Z),shading flat, title('Grafica Mesh :B'), xlabel('x'), ylabel('y'), xlabel('z');


>> subplot(1,2,2);

>> surf(X,Y,Z),shading interp, title('Grafica Mesh :B'), xlabel('x'), ylabel('y'), xlabel('z');

otro ejemplo:

>> x= [-10:0.1:10];

>> y=x;

>> [X,Y]=meshgrid(x,y);

>> Z=sin(sqrt(X.^2+Y.^2))./sqrt(X.^2+Y.^2+0.1);

>> colormap(hot);

>> surf(X,Y,Z), shading interp; %sombreado con interpolacin de colores

>> colormap('default')

para cambiar:

meshc(X,Y,Z), shading interp; %sombreado con interpolacin de colores

>> surfc(X,Y,Z), shading interp; %sombreado con interpolacin de colores

>> surfl(X,Y,Z), shading interp; %sombreado con interpolacin de colores

>> surfl(X,Y,Z), shading interp; %cambia la iluminacin de los colores

>> waterfall(X,Y,Z), shading interp; %cambia la iluminacin de los colores

>> contour(X,Y,Z), shading interp; %cambia la iluminacin de los colores

>> contour3(X,Y,Z), shading interp; %cambia la iluminacin de los colores

>> c=contour3(X,Y,Z);

>> clabel(c);

----------------
x = linspace(0,3,50);

e1 = exp(-x.^2);

e2 = (x.^2).*exp(-x.^2);

e3 = x.*(exp(-x.^2));

e4 = exp(-x);

plot(x,e1,'+-r',x,e2,'+-b',x,e3,'+-g',x,e4,'+-y')

---------------------------------------------------

t= 0:0.2:2*pi+0.2;

x=sin(t);

y=cos(t);

subplot(3,1,1);

plot(x,y,'-');

subplot(3,1,2);

plot(x,y,'-');

axis square;

subplot(3,1,3);

plot(x,y,'-');

axis normal; grid;

axis([-2 2 -3 3]);

title('Grfica De Crculos')

-----------------------------------------------------

x = [1 5 4 2];

y = [1 0 4 3];

fill(x,y,'r')

fill(x,y[0.2 0.6 0.5])

fill(x,y[0.2 0.6 0.5])


Error: Unbalanced or unexpected parenthesis or bracket.

fill(x,y,[0.2 0.6 0.5])

fill(x,y,[0.8 0.6 0.5])

fill(x,y,[1 0.8 0.6 0.5])

colormap(gray),fill(x,y,[1 0.5 0.8 0.7])

x = [1 1 4 6; 2 -2 2 -5; 3 -2 1 -1]

x=

1 1 4 6

2 -2 2 -5

3 -2 1 -1

fill(x,y[0.2 0.6 0.5]

---------------------------------------------------------

>> x = (-1:.1:1);

>> y = x.^2-2*x-5/6;

>> plot (x,y);

>> x = (-1:.1:1);

>> y = x.^2-2*x-5/6;

>> plot (x,y); grid;

>> hold on

>> plot (x,-y);

>> xlabel('x')
>> ylabel('y')

>> title('Grafica 8')

>>

>> x = (-2:.1:2);

>> y = x.^2-2*x-5/6;

>> plot (x,y); grid;

>> xlabel('x')

>> ylabel('y')

>> title('Grafica 8')

>>

>> x = (-3:.1:3);

>> y = x.^2-2*x-5/6;

>> plot (x,y); grid;

>>

200

También podría gustarte