Вы находитесь на странице: 1из 27

Trabajo

Laboratorio
Mtodos
Numricos
2013

APELLIDOS Y
NOMBRES:
YAGUA
HUAMAYALLI,
JUAN JOSE

Trabajo Laboratorio Mtodos Numricos


CAPITULO 1
Ejercicios propuestos:
1.

Qu muestra la ventana current directory?

Directorio actual, rea en la cual es exhibida la lista de los archivos y directorios contenidos en el directorio
actual.
2.

Listar (sin cambiar de path) el directorio raz de la unidad C.

>> dir
.

extern

license.txt

..

help

licenses

appdata

ja

notebook

bin

java

patents.txt

etc

lib

3.

resources
rtw

sys
toolbox

runtime
simulink

trademarks.txt
uninstall

practicando matlab stateflow

Crear en la carpeta C:\, la subcarpeta COLOR

>> mkdir color

4.

Cambiar el path de trabajo a COLOR.

>> cd c:\Program Files\MATLAB\R2011a\gato

5.

Copiar todos los archivos de C:\MATLAB7\TOOLBOX\MATLAB\ELFUN\JA, a la carpeta


COLOR.

>> copyfile('C:\Program Files\MATLAB\R2011a\ELFUN\JA*.txt')

6.

Duplicar los archivos de la carpeta COLOR que comiencen con m y tengan extensin m asignando
a los duplicados la letra inicial p y la extensin p.

>> copyfile('m*.m', 'p.p')

METODOS NUMERICOS

Trabajo Laboratorio Mtodos Numricos


7.

Borrar todos los archivos que comiencen con m y tengan extensin m.

>> delete m*.m


CAPITULO 2
Ejercicios propuestos:
1. Hallar las dimensiones, la traza, el determinante, el rango y la inversa de la matrizA.
A=[2,3,7;2,1,1;1,2,3].
>> A=[2,3,7;2,1,1;1,2,3]
A=
2

>> diag(A)
ans =
2
1
3
>> det(A)
ans =
8
>> rank(A)
ans =
3
>> inv(A)
ans =
0.1250

0.6250 -0.5000

-0.6250 -0.1250

1.5000

0.3750 -0.1250 -0.5000

METODOS NUMERICOS

Trabajo Laboratorio Mtodos Numricos

2. Crear una matriz de dos columnas con la diagonal y antidiagonal de la matriz


A=[2,3,7;2,1,1;1,2,3].
>> A=[2,3,7;2,1,1;1,2,3]

A=
2

>> B=diag(A)
B=
2
1
3
>> C=diag(fliplr(A))
C=
7
1
1
>> D=[B,C]
D=
2

METODOS NUMERICOS

Trabajo Laboratorio Mtodos Numricos

CAPITULO 3

>> %sea una matriz A*X=B donde:


>> A=[2 3 -4; 1 -2 1; 1 -7 14]
A=
2

-4

-2

-7

14

>> B=[3;0;2]
B=
3
0
2
>> X=A\B
X=
1.1967
0.8361
0.4754

METODOS NUMERICOS

Trabajo Laboratorio Mtodos Numricos

>> %sea una matriz A*X=B donde:


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

-1

-1

-1

-1

-1

>> B=[4;1;-3;4]
B=
4
1
-3
4
>> X=A\B
X=
-1.0000
2.0000
-0.0000
1.0000

METODOS NUMERICOS

Trabajo Laboratorio Mtodos Numricos

>> %sea la matriz A y B donde:


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

-1

-5

>> b1= [1;0;1;0]


b1 =
1
0
1
0
>> X=A\b1
X=
-0.4444
-0.1111
-0.3333
1.6667
>> b2=[1;2;3;4]
b2 =
1
2
3

METODOS NUMERICOS

Trabajo Laboratorio Mtodos Numricos


4
>> X=A\b2
X=
-0.2222
-0.5556
2.3333
2.3333
>> b3=[-1;0;2;-3]
b3 =
-1
0
2
-3
>> X=A\b3
X=
2.4444
-0.8889
0.3333
-1.6667
>> B=[-1 3 2 0.5;2 -6 -1 0;0 6 2 1;5 -3 0 2]
B=
-1.0000

3.0000

2.0000

0.5000

2.0000 -6.0000 -1.0000


0

6.0000

2.0000

5.0000 -3.0000

1.0000
2.0000

>> X=B\b1
X=
0.8333

METODOS NUMERICOS

Trabajo Laboratorio Mtodos Numricos


0.0556
1.3333
-2.0000
>> X=B\b2
X=
5.1667
0.6111
4.6667
-10.0000
>> X=B\b3
X=
6.6667
1.4444
4.6667
-16.0000

>> %factorizar la matriz A por gauss doolitle y ortogonalmente.

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


A=
1

METODOS NUMERICOS

Trabajo Laboratorio Mtodos Numricos


0

>> [L,U]=lu(A)
L=
1.0000

1.0000

0.6667

0.8000 0.5000

1.0000

1.0000

0.6667

1.0000

1.0000

1.0000

0.6667

0
0

0.6000

1.0000

U=
1.0000

1.0000

1.0000 1.0000

3.0000

1.0000

1.0000

2.0000

5.0000 -0.6667 -1.3333


3.7333

4.4667

0 3.5000

>> [L,U,P]=lu(A)
L=
1.0000

1.0000

1.0000

1.0000

0.6667

1.0000

0.6667

1.0000

0
0

0.6000

0
0

1.0000

0.6667

0.8000 0.5000

1.0000

1.0000

1.0000 1.0000

1.0000

U=
1.0000
0

3.0000

1.0000

2.0000

5.0000 -0.6667 -1.3333


3.7333

4.4667

0 3.5000

METODOS NUMERICOS

Trabajo Laboratorio Mtodos Numricos

P=
1

>> [Q,R]=qr(A)
Q=
-0.5000

0.5916

0.1280

0.4907

-0.5000 -0.0845 -0.3231

0.3780

0.2590 -0.7559

-0.5000 -0.0845 -0.5364 -0.5588

0.3780

-0.5000 -0.4226

0.0000

0.7314 -0.1908

0 -0.6761 -0.2377

0.5861

0.3780

R=
-2.0000 -5.5000 -6.5000 -3.5000 -6.0000
0

-2.9580 -2.7890 -3.2961 -4.7329

-4.6874 -0.8655 -1.6640


0

2.6714

4.1026

0 -2.6458

>> Q*R
ans =
1.0000

1.0000

1.0000 1.0000

1.0000

1.0000

3.0000

5.0000 3.0000

7.0000

1.0000

3.0000

6.0000 1.0000

1.0000

1.0000

4.0000

1.0000 2.0000

3.0000

2.0000

3.0000

5.0000

METODOS NUMERICOS

4.0000

10

Trabajo Laboratorio Mtodos Numricos

>> A
A=
1

>> A(2,:)=A(2,:)-A(1,:) %accion fila 2-fila1>>fila2


A=
1

>> A(3,:)=A(3,:)-A(1,:)
A=
1

>> A(4,:)=A(4,:)-A(1,:)

METODOS NUMERICOS

11

Trabajo Laboratorio Mtodos Numricos

A=
1

CAPITULO 4
6. Evaluar los polinomios en x = 1:0.3:7

i.

P2=2x5 + 3ix +( 6-2i)

ii.

P3=x10+ x+ 1

En Matlab:
i)
>> p2=[2,0,0,0,3i,6-2i];
>> x=1:0.3:7;
>> polyval(p2,x)
ans =
1.0e+004 *
Columns 1 through 2
0.0008 + 0.0001i 0.0013 + 0.0002i
Columns 3 through 4
0.0027 + 0.0003i 0.0056 + 0.0004i
Columns 5 through 6
0.0109 + 0.0005i 0.0201 + 0.0006i
Columns 7 through 8
0.0350 + 0.0006i 0.0579 + 0.0007i
Columns 9 through 10

METODOS NUMERICOS

12

Trabajo Laboratorio Mtodos Numricos


0.0915 + 0.0008i 0.1393 + 0.0009i

Columns 11 through 12
0.2054 + 0.0010i 0.2946 + 0.0011i
Columns 13 through 14
0.4125 + 0.0012i 0.5656 + 0.0013i
Columns 15 through 16
0.7610 + 0.0014i 1.0072 + 0.0014i
Columns 17 through 18
1.3133 + 0.0015i 1.6898 + 0.0016i
Columns 19 through 20
2.1481 + 0.0017i 2.7009 + 0.0018i
Column 21
3.3620 + 0.0019i

ii)
>> p3=[1,0,0,0,0,0,0,0,0,1,1];
>> x=1:0.3:7;
>> polyval(p3,x)
ans =
1.0e+008 *
Columns 1 through 4
0.0000

0.0000

0.0000 0.0000

Columns 5 through 8
0.0000

0.0001

0.0003 0.0008

Columns 9 through 12
0.0021

0.0048

0.0105 0.0216

Columns 13 through 16
0.0424

0.0798

0.1446 0.2533

Columns 17 through 20

METODOS NUMERICOS

13

Trabajo Laboratorio Mtodos Numricos


0.4308

0.7133

1.1529 1.8228

Column 21
2.8248

7. Hallar el desarrollo del trinomio p(x) =( x3 - ix+2)4 usando los comandos de Matlab
En Matlab:
>> p=[1 0 -i 2];
>> q=conv(p,p)
q=
Columns 1 through 4
1.0000

0 - 2.0000i 4.0000

Columns 5 through 7
-1.0000

0 - 4.0000i 4.0000

>> r=conv(q,p)
r=
Columns 1 through 4
1.0000

0 - 3.0000i 6.0000

Columns 5 through 8
-3.0000

0 -12.0000i 12.0000 + 1.0000i -6.0000

Columns 9 through 10
0 -12.0000i 8.0000

>> conv(r,p)
ans =

METODOS NUMERICOS

14

Trabajo Laboratorio Mtodos Numricos


Columns 1 through 4
1.0000

0 - 4.0000i 8.0000

Columns 5 through 8
-6.0000

0 -24.0000i 24.0000 + 4.0000i -24.0000

Columns 9 through 12
1.0000 -48.0000i 32.0000 + 8.0000i -24.0000

0 -32.0000i

Column 13
16.0000
9. Hallar el resto de la divisin de p(x) por d(x)= x3 - ix+2, siendo p(x) el polinomio
Caracterstico de la matriz A.
11111
13537
13611
14123
02345

A=

En Matlab:
>> A=[1,1,1,1,1;1,3,5,3,7;1,3,6,1,1;1,4,1,2,3;0,2,3,4,5]
A=
1
1
1
1
0

1
3
3
4
2

1
5
6
1
3

1
3
1
2
4

1
7
1
3
5

>> poly(A)
ans =
Columns 1 through 4
1.0000 -17.0000 47.0000 -4.0000
Columns 5 through 6
203.0000 -196.0000
>> P=poly(A);
>> [Q,R]=deconv(P,[1,0,-i,2])

METODOS NUMERICOS

15

Trabajo Laboratorio Mtodos Numricos

Q=
Columns 1 through 2
1.0000

-17.0000

Column 3
47.0000 + 1.0000i

R=
1.0e+002 *
Columns 1 through 2
0

Columns 3 through 4
0

-0.0600 - 0.1700i

Columns 5 through 6
2.3600 + 0.4700i -2.9000 - 0.0200i

10. Hallar la derivada del cociente de la divisin de P(x)=x10+ x+ 1 por


D(x)= x3-i x+ 2
En Matlab:
>> p=[1,0,0,0,0,0,0,0,0,1,1];
>> d=[1,0,-i,2];
>> [Q,R]=deconv(p,d)
Q=
Columns 1 through 2
1.0000

Columns 3 through 4

METODOS NUMERICOS

16

Trabajo Laboratorio Mtodos Numricos


0 + 1.0000i -2.0000
Columns 5 through 6
-1.0000

0 - 4.0000i

Columns 7 through 8
4.0000 - 1.0000i 6.0000
R=
Columns 1 through 2
0

Columns 3 through 4
0

Columns 5 through 6
0

Columns 7 through 8
0

Columns 9 through 10
1.0000 +12.0000i -7.0000 + 8.0000i
Column 11
-11.0000
>> D=polyder(Q)
D=
Columns 1 through 2
7.0000

Columns 3 through 4
0 + 5.0000i -8.0000
Columns 5 through 6
-3.0000

0 - 8.0000i

Column 7
4.0000 - 1.0000i

METODOS NUMERICOS

17

Trabajo Laboratorio Mtodos Numricos

11. Hallar las races de la funcin f(x)= xsenx+2 cercanas a 6, 4, 4 y 6.


En Matlab:
>> fzero('x.*sin(x)+2',-6)
ans =
-5.9398
>> fzero('x.*sin(x)+2',-4)
ans =
-3.7108
>> fzero('x.*sin(x)+2',6)
ans =
5.9398
>> fzero('x.*sin(x)+2',4)
ans =
3.7108

METODOS NUMERICOS

18

Trabajo Laboratorio Mtodos Numricos

CAPITULO 5

1. Crear el archivo tipo texto datos.txt con los datos

1. 0 7.5
2. 5 4.0
3. 2 5.0
3. 5 5.5
2. 0 6.3
7. 8 6.2
8. 1 6.0
9. 7 5.0
10. 3 3.0

METODOS NUMERICOS

19

Trabajo Laboratorio Mtodos Numricos

2. Graficar usando este archivo la 1ra columna versus la 2da columna a travs
de una poligonal lineal, use textread para leer los datos de este archivo.
>> textread('PREGUNTA1MATLAB.txt')
ans =
1.0000

7.5000

2.5000

4.0000

3.2000

5.0000

3.5000

5.5000

2.0000

6.3000

7.8000

6.2000

8.1000

6.0000

9.7000

5.000

10.3000

3.0000

>> [col1,col2]=textread('PREGUNTA1MATLAB.txt')
col1 =
1.0000
2.5000
3.2000
3.5000
2.0000
7.8000
8.1000

METODOS NUMERICOS

20

Trabajo Laboratorio Mtodos Numricos


9.7000
10.3000

col2 =
7.5000
4.0000
5.0000
5.5000
6.3000
6.2000
6.0000
5.0000
3.0000

>> plot(col1,col2)

METODOS NUMERICOS

21

Trabajo Laboratorio Mtodos Numricos

3. Graficar :
a. x2-y2=3
>> x= 0:0.5:5;
>> y=sqrt((x.^2)-3);
>> plot(x,y)

b. [[x]]+ lyl = 10
>> x=0:0.5:5;
>> y=10-floor(x);
>>plot(x,y)

METODOS NUMERICOS

22

Trabajo Laboratorio Mtodos Numricos

4. Grafique las funciones polares:

a) r1 2sen(3), 0:/ 20: 2


>> a=0:pi/20:2*pi;
>> polar(a,2*sin(3*a));

METODOS NUMERICOS

23

Trabajo Laboratorio Mtodos Numricos

b) r2 5, 0:/ 20: 2
>> a=0:pi/20:2*pi;
>> polar(a,5*a)

c) r3 2
sen(), 0: /
20: 2
>> a=0:pi/20:2*pi;
>> polar(a,2-sin(a))

METODOS NUMERICOS

24

Trabajo Laboratorio Mtodos Numricos

5.

Use subplot para dividir la ventana en 1x2 para luego graficar en ellas las
siguientes curvas paramtricas (R R2).

SOLUCION:
>> subplot(1,2,1);
>> syms t, ezplot(sin(t),sin(2*t),[0,2 *pi]);
>> subplot(1,2,2);
>> syms t, ezplot(sin(t),cos(t),[0,2 *pi]);

METODOS NUMERICOS

25

Trabajo Laboratorio Mtodos Numricos

METODOS NUMERICOS

26

Вам также может понравиться