La descarga está en progreso. Por favor, espere

La descarga está en progreso. Por favor, espere

Matlab Matrices. Matriz como tabla de números >> notas=[4.5,5.6; 5.3, 6.2; 3.7,4.9] notas = 4.5000 5.6000 5.3000 6.2000 3.7000 4.9000 >> v=size(notas)

Presentaciones similares


Presentación del tema: "Matlab Matrices. Matriz como tabla de números >> notas=[4.5,5.6; 5.3, 6.2; 3.7,4.9] notas = 4.5000 5.6000 5.3000 6.2000 3.7000 4.9000 >> v=size(notas)"— Transcripción de la presentación:

1 Matlab Matrices

2 Matriz como tabla de números >> notas=[4.5,5.6; 5.3, 6.2; 3.7,4.9] notas = 4.5000 5.6000 5.3000 6.2000 3.7000 4.9000 >> v=size(notas) %devuelve vector v = 3 2 >> filas=v(1) % n° de filas en primer elemento (de índice 1) filas = 3 >> cols=v(2) % n° de filas en 2° elemento (de índice 2) cols = 2 >> [filas, cols]=size(notas); %resultado en vector de 2 elementos

3 Promedios por filas >> notas(1,3)=(notas(1,1)+notas(1,2))/2 %M(n°fila, n°columna) notas = 4.5000 5.6000 5.0500 5.3000 6.2000 0 3.7000 4.9000 0 >> notas(1,3)=mean(notas(1,1:2)); %M(n°fila, n°col inicial:n°col final) >> notas(2,3)=mean(notas(2,1:2)); %promedio fila 2 >> notas(3,3)=mean(notas(3,1:2)) %promedio fila 3 notas = 4.5000 5.6000 5.0500 5.3000 6.2000 5.7500 3.7000 4.9000 4.3000

4 Promedios por columnas >> notas(4,1)=mean(notas(1:3,1)) % M(i1:i2,j) notas = 4.5000 5.6000 5.0500 5.3000 6.2000 5.7500 3.7000 4.9000 4.3000 4.5000 0 0 >> notas(4,2)=mean(notas(1:3,2)); % promedio columna 2 >> notas(4,3)=mean(notas(1:3,3)) % promedio columna 3 notas = 4.5000 5.6000 5.0500 5.3000 6.2000 5.7500 3.7000 4.9000 4.3000 4.5000 5.5667 5.0333

5 Estadígrafos por columnas >> notas(5,3)=median(notas(1:3,3)) ; >> notas(6,3)=mode(notas(1:3,3)) ; >> notas(7,3)=max(notas(1:3,3)) ; >> notas(8,3)=min(notas(1:3,3)) ;

6 Producto de vectores >> a = [1, 2, 3, 4]; >> b = [5; 6; 7; 8]; >> producto=a*b % suma de productos entre elementos producto = 70 >> c=b‘ % traspuesto (convierte columna a fila) c = 5 6 7 8 >> producto=sum(a.*c) producto = 70

7 Producto de Matrices >> A A = 1 2 3 4 5 6 >> B B = 1 4 2 5 3 6 >> C=A*B % cada C(i,j)=sum(A(i,:).* B(:,J)’) suma de fila i por columna j C = 14 32 32 77

8 Matrices Cuadradas >> A=[1 2; 3 4]; >> B=inv(A) %matriz inversa B = -2.0000 1.0000 1.5000 -0.5000 >> C=A*B C = 1.0000 0.0000 0.0000 1.0000 >> I=eye(2,2) %matriz identidad >> A1=A*I % I es neutro en producto I = A1 = 1 0 1 2 0 1 3 4 >> AA=A^2 %AA=A*A potencia AA = 7 10 15 22

9 Matriz Inversa %matriz de 2 x 2 x=[ nº nº ; nº nº ]; %determinante d=det(x) %d=x(1,1)*x(2,2) – x(1,2)*x(2,1); %matriz inversa inversa=1/d * [x(2,2), –x(1,2); -x(2,1), x(1,1)]; %matriz de 3 x 3 x=[ nº nº n°; n° n° n°; n° nº nº ]; %determinante M1=[x(2,2) x(2,3); x(3,2) x(3,3)]; M2=[x(2,1) x(2,3); x(3,1) x(3,3)]; M3=[x(2,1) x(2,2); x(3,1) x(3,2)]; d=det(x) %d=x(1,1)*det(M1) – x(1,2)*det(M2) + x(1,3)*det(M3); %matriz inversa inversa=1/d * [x(2,2)*x(3,3)-x(2,3)*x(3,2), x(1,3)*x(3,2)-x(1,2)*x(3,3), x(1,2)*x(2,3)-x(1,3)*x(2,2); x(2,3)*x(3,1)-x(2,1)*x(3,3), x(1,1)*x(3,3)-x(1,3)*x(3,1), x(1,3)*x(2,1)-x(1,1)*x(2,3); x(2,1)*x(3,2)-x(2,2)*x(3,1), x(1,2)*x(3,1)-x(1,1)*x(3,2), x(1,1)*x(2,2)-x(1,2)*x(2,1)];

10 Sistema Ecuaciones Lineales a 11 x 1 + a 12 x 2 +... + a 1n x n = b 1... a n1 x 1 + a n2 x 2 +... + a nn x n = b n Ejemplo 2x + y – 2z = 10 3x + 2y +2z = 1 5x +4y + 3z = 4

11 Solución Algebraica a 11 x 1 + a 12 x 2 +... + a 1n x n = b 1... a n1 x 1 + a n2 x 2 +... + a nn x n = b n El sistema corresponde a multiplicar la matriz A (con los coeficientes a ij ) por el vector x (con las incógnitas x i ):

12 Solución Algebraica A x = b multiplicando cada lado de la igualdad por la inversa de A A -1 A x = A -1 b I x = A -1 b x = A -1 b

13 Solución en Matlab >> A=[2 1 -2 ; 3 2 2 ; 5 4 3] A = 2 1 -2 3 2 2 5 4 3 >> b=[10 ; 1; 4] b = 10 1 4 >> x=inv(A)*b x = 1.0000 2.0000 -3.0000 >> x=A^-1*b %o x=A\b usando operador \ x = 1.0000 2.0000 -3.0000


Descargar ppt "Matlab Matrices. Matriz como tabla de números >> notas=[4.5,5.6; 5.3, 6.2; 3.7,4.9] notas = 4.5000 5.6000 5.3000 6.2000 3.7000 4.9000 >> v=size(notas)"

Presentaciones similares


Anuncios Google