You are on page 1of 44

INFORME DE LABORATORIO N 3 ILIZARBE AVILA Miguel Alejandro

EJERCICIO 1 >> U = [1 2 3 4 5]; V = [6 7 8 9 10]; >> % apartado a >> 3*U ans = 3 6 9 12 15

>> U+V ans = 7 >> U-V ans = -5 -5 -5 -5 -5 >> % APARTADO B >> V+3 ans = 9 10 11 12 13 >> % APARTADO C >> U.*V ans = 6 14 24 36 50 9 11 13 15

>> %APARTADO D >> U.^3 ans = 1 8 27 64 125

>> %APARTADO E >> U.^V ans = 1 >> 128 6561 262144 9765625

EJERCICIO 2

>> A = [1 2 1;5 4 3;7 1 0]; B = [-2 5 7;4 3 1;8 -1 3]; >> A A= 1 5 7 >> B B= -2 4 5 3 7 1 3 2 4 1 1 3 0

8 -1

>> %APARTADO A >> A+B ans = -1 9 15 >> A*B ans = 14 10 12 30 34 48 -10 38 50 >> A^4 ans = 914 2366 1164 643 1653 834 383 985 490 7 7 0 8 4 3

>> % APARTADO B >> A.*B ans = -2 10 20 12 56 -1 7 3 0

>> % APARTADO C >> A./B ans = -0.5000 0.4000 0.1429 1.2500 1.3333 3.0000 0.8750 -1.0000 >> 0

EJERCICIO 3 >> help matlap\malfun

Matrix functions - numerical linear algebra.

Matrix analysis. norm normest rank det trace null orth rref - Matrix or vector norm. - Estimate the matrix 2-norm. - Matrix rank. - Determinant. - Sum of diagonal elements. - Null space. - Orthogonalization. - Reduced row echelon form.

subspace - Angle between two subspaces.

Linear equations. / and / - Linear equation solution; use "help slash".

linsolve - Linear equation solution with extra control. inv rcond cond condest - Matrix inverse. - LAPACK reciprocal condition estimator - Condition number with respect to inversion. - 1-norm condition number estimate.

normest1 - 1-norm estimate. chol ldl lu qr - Cholesky factorization. - Block LDL' factorization. - LU factorization. - Orthogonal-triangular decomposition.

lsqnonneg - Linear least squares with nonnegativity constraints. pinv lscov - Pseudoinverse. - Least squares with known covariance.

Eigenvalues and singular values. eig svd gsvd eigs svds poly polyeig - Eigenvalues and eigenvectors. - Singular value decomposition. - Generalized singular value decomposition. - A few eigenvalues. - A few singular values. - Characteristic polynomial. - Polynomial eigenvalue problem.

condeig hess schur qz

- Condition number with respect to eigenvalues. - Hessenberg form. - Schur decomposition.

- QZ factorization for generalized eigenvalues.

ordschur - Reordering of eigenvalues in Schur decomposition. ordqz ordeig - Reordering of eigenvalues in QZ factorization. - Eigenvalues of quasitriangular matrices.

Matrix functions. expm logm sqrtm funm - Matrix exponential. - Matrix logarithm. - Matrix square root. - Evaluate general matrix function.

Factorization utilities qrdelete - Delete a column or row from QR factorization. qrinsert - Insert a column or row into QR factorization. rsf2csf cdf2rdf balance - Real block diagonal form to complex diagonal form. - Complex diagonal form to real block diagonal form. - Diagonal scaling to improve eigenvalue accuracy.

planerot - Givens plane rotation. cholupdate - rank 1 update to Cholesky factorization. qrupdate - rank 1 update to QR factorization.

Matrix functions - numerical linear algebra.

Matrix analysis. norm normest rank det trace null orth rref - Matrix or vector norm. - Estimate the matrix 2-norm. - Matrix rank. - Determinant. - Sum of diagonal elements. - Null space. - Orthogonalization. - Reduced row echelon form.

subspace - Angle between two subspaces.

Linear equations. / and / - Linear equation solution; use "help slash".

linsolve - Linear equation solution with extra control. inv rcond cond condest - Matrix inverse. - LAPACK reciprocal condition estimator - Condition number with respect to inversion. - 1-norm condition number estimate.

normest1 - 1-norm estimate. chol ldl lu qr - Cholesky factorization. - Block LDL' factorization. - LU factorization. - Orthogonal-triangular decomposition.

lsqnonneg - Linear least squares with nonnegativity constraints. pinv lscov - Pseudoinverse. - Least squares with known covariance.

Eigenvalues and singular values. eig svd gsvd eigs svds poly polyeig condeig hess schur qz - Eigenvalues and eigenvectors. - Singular value decomposition. - Generalized singular value decomposition. - A few eigenvalues. - A few singular values. - Characteristic polynomial. - Polynomial eigenvalue problem. - Condition number with respect to eigenvalues. - Hessenberg form. - Schur decomposition. - QZ factorization for generalized eigenvalues.

ordschur - Reordering of eigenvalues in Schur decomposition. ordqz ordeig - Reordering of eigenvalues in QZ factorization. - Eigenvalues of quasitriangular matrices.

Matrix functions. expm logm sqrtm funm - Matrix exponential. - Matrix logarithm. - Matrix square root. - Evaluate general matrix function.

Factorization utilities qrdelete - Delete a column or row from QR factorization. qrinsert - Insert a column or row into QR factorization.

rsf2csf cdf2rdf balance

- Real block diagonal form to complex diagonal form. - Complex diagonal form to real block diagonal form. - Diagonal scaling to improve eigenvalue accuracy.

planerot - Givens plane rotation. cholupdate - rank 1 update to Cholesky factorization. qrupdate - rank 1 update to QR factorization. >> % APARTADO A >> inv(A) ans = -0.1875 0.0625 0.1250 1.3125 -0.4375 0.1250 -1.4375 0.8125 -0.3750 >> inv(B) ans = -0.0424 0.0932 0.0678 0.0169 0.2627 -0.1271 0.1186 -0.1610 0.1102 >> A*inv(A) ans = 1.0000 0.0000 0

0.0000 1.0000 0.0000 0.0000 0 1.0000

>> % APARTADO B >> trace(B) ans = 4 >> %APARTADO C >> det(A) ans = 16.0000 >> rank(A) ans =

>>

EJERCICIO 4 >> % APARTADO A >> referencia = [100 101 102 103]; >> referencia referencia = 100 101 102 103 >> cantidad = [200 150 500 49]; >> cantidad cantidad = 200 150 500 49 >> precio = [190 345 69 598]; >> precio precio = 190 345 69 598

>>

>> % APARTADO B >> costototaldeproduccion = cantidad.* precio costototaldeproduccion = 38000 51750 34500 29302

>> % APARTADO C >> [referencia'.costototaldeproduccion'] ??? [referencia'.costototaldeproduccion'] Error: Unexpected MATLAB operator. >> [referencia',costototaldeproduccion']

ans =

100 101 102 103

38000 51750 34500 29302

>>

>> % APARTADO D >> >> sum(costototaldeproduccion*0.16+costototaldeproduccion) ans = 1.7812e+005

>>

EJERCICIO 5 >> u = [2 3 4]; v = [3 -4 8]; >> >> u u= 2 >> v v= 3 -4 8 3 4

>> %APARTADO A >> sum(u),prod(u) ans = 9

ans = 24 >> %APARTADO B >> >> max(v) ans = 8 >> %si no se guarda la salida en dos variables solo nos devuelve el valor del maximo de los elementos >> %del vector >> >> [p,q]= max(v) p= 8 q= 3 >> [p,q]= min(v) p= -4 q= 2 >> %APARTADO C >> >> dot(u,v) ans = 26

>> % tambien se pude realizar como >> >> sum(u.*v) ans = 26 >> >> %APARTADO D >> >> norm(u),norm(v) ans = 5.3852 ans = 9.4340 >> %se podria realizar tambien >> >> sqrt(dot(u,u)) ans = 5.3852 >>

EJERCICIO 6 >> %APARTADO A >> >> x = 10:100 x= Columns 1 through 12

10 11 12 13 14 15 16 17 18 19 20 21

Columns 13 through 24

22 23 24 25 26 27 28 29 30 31 32 33

Columns 25 through 36

34 35 36 37 38 39 40 41 42 43 44 45

Columns 37 through 48

46 47 48 49 50 51 52 53 54 55 56 57

Columns 49 through 60

58 59 60 61 62 63 64 65 66 67 68 69

Columns 61 through 72

70 71 72 73 74 75 76 77 78 79 80 81

Columns 73 through 84

82 83 84 85 86 87 88 89 90 91 92 93

Columns 85 through 91

94 95 96 97 98 99 100

>>

>> % APARTADO B >> >> y = -1:0.2:2 y= Columns 1 through 7

-1.0000 -0.8000 -0.6000 -0.4000 -0.2000

0 0.2000

Columns 8 through 14

0.4000 0.6000 0.8000 1.0000 1.2000 1.4000 1.6000

Columns 15 through 16

1.8000 2.0000

>> % APARTADO C >> >> linspace(1,3,38)

ans =

Columns 1 through 7

1.0000 1.0541 1.1081 1.1622 1.2162 1.2703 1.3243

Columns 8 through 14

1.3784 1.4324 1.4865 1.5405 1.5946 1.6486 1.7027

Columns 15 through 21

1.7568 1.8108 1.8649 1.9189 1.9730 2.0270 2.0811

Columns 22 through 28

2.1351 2.1892 2.2432 2.2973 2.3514 2.4054 2.4595

Columns 29 through 35

2.5135 2.5676 2.6216 2.6757 2.7297 2.7838 2.8378

Columns 36 through 38

2.8919 2.9459 3.0000

>>

EJERCICIO 7 >> u = [1 2 3]; v = [4 5 6]; >> u u= 1 >> v v= 4 5 6 2 3

>> % APARTADO DE A >> u1 = [0,u] u1 = 0 1 2 3

>> % APARTADO B >> >> uv = [u,v] uv = 1 2 3 4 5 6

>>

EJERCICIO 8 >> % APARTADO A >> w = (1:15).^2 w= Columns 1 through 12

9 16 25 36 49 64 81 100 121 144

Columns 13 through 15

169 196 225

>> w(7) ans = 49 >> % APARTADO B >> w(2:6) ans = 4 9 16 25 36

>> % APARTADO C >> w(13:-1:7) ans = 169 144 121 100 81 64 49

>> % APARTADO D >> >> v = w ([1,3,7,14]) v= 1 >> 9 49 196

EJERCICIO 9

>> A = [2 -8 3 4;1 2 4 -2;-1 3 6 -9;5 7 -4 0] A= 2 -8 1 -1 5 2 3 3 4

4 -2 6 -9 0

7 -4

>> % APARTADO A >> A(2,3) ans = 4

>> % APARTADO B >> A (2,2)= 100 A= 2 -8 1 100 -1 5 3 3 4

4 -2 6 -9 0

7 -4

>> % se podria hacer desde el workspace >> % APARTADO C >> AA = A(2:4,1:3) AA = 1 100 -1 5 3 4 6

7 -4

>> % APARTADO D >> A (3,:) ans = -1 3 6 -9

>> % APARTADO E >> A(:,1) ans =

2 1 -1 5

>> % APARTADO F >> C = A (1:3,:) C= 2 -8 1 100 -1 3 3 4

4 -2 6 -9

>> % APARTADO G >> D = A ([1,4],:) D= 2 -8 5 3 4 0

7 -4

>>

EJERCICIO 10 >> A = rand (3)

A=

0.1190 0.3404 0.7513 0.4984 0.5853 0.2551 0.9597 0.2238 0.5060

>> %APARTADO A >> >> inv (A)

ans =

-0.7655 0.0131 1.1301 0.0235 2.1163 -1.1019 1.4417 -0.9609 0.3202

>> A'

ans =

0.1190 0.4984 0.9597 0.3404 0.5853 0.2238 0.7513 0.2551 0.5060

>> diag(A)

ans =

0.1190 0.5853 0.5060

>> tril(A)

ans =

0.1190

0 0

0.4984 0.5853

0.9597 0.2238 0.5060

>> % APARTADO C >> % SUMA DE LOS ELEMENTOS DE LA PRIMERA FILA >> % PRIMER CAMINO: >> A(1,1)+A(1,2)+A(1,3)

ans =

1.2107

>> % SEGUNDO CAMINO >> sum(A(1,:))

ans =

1.2107

>> % SUMA DE LOS ELEMENTOS DE LA SEGUNDA COLUMNA >> sum(A(2,:))

ans =

1.3387

>> %SUMA DE LA DIAGONAL >> sum(diag(A))

ans =

1.2102

>> >>

EJERCICIO 11

>> A=[1 2 3;1 3 8;2 3 1;5 6 4]

A=

1 1 2 5

2 3 3 6

3 8 1 4

>> AA=[1 2 3 6;1 3 8 19;2 3 1 -1;5 6 4 5]

AA =

1 1 2 5

2 3 3 6

8 19 1 -1 4 5

>> % Comparamos rangos >> [rank(A),rank(AA)]

ans =

>> % El sistema es compatible y determinado >> % Resolvemos >> b=AA(:,4)

b=

6 19 -1 5

>> A\b

ans =

1.0000 -2.0000 3.0000

>> % Nota: Existen comandos de resolucin como linsolve >> x=linsolve(A,b)

x=

1.0000 -2.0000 3.0000

>>

EJERCICIO 12 >> % APARTADO A >> A=[1 3 5 1;2 1 3 1;4 1 2 2;5 1 2 3]

A=

1 2 4 5

3 1 1 1

5 3 2 2

1 1 2 3

>> rank(A)

ans =

>> % Existe inversa de A >> b = [1 2 1 5]

b=

>> % resolvemos: >> x=inv(A)*b'

x=

-3.2857 -3.8571 1.7143 7.2857

>> %APARTADO B >> x=A\b'

x=

-3.2857 -3.8571 1.7143 7.2857

>>

You might also like