Sunteți pe pagina 1din 41

FACULTAD DE INGENIERIA DE SISTEMAS

ASIGNATURA: MTODOS NUMRICOS


APELLIDOS Y NOMBRES: QUISPEALAYA SALVATIERRA AMANCIO
a) Taylor(exp(-x))
syms x
t = Taylor(exp(-x))
;
ezplot(t)
title('FUNCION DE TAYLOR')
xlabel('x')
ylabel('fx')
grid

SOL= 1-x+1/2*x 2-1/6*x 3+1/24*x 4-1/120*x 5


150

fx

100

50

-50
-6

-4

-2

0
x

b) taylor( log(x),6,1)
syms m
m= taylor( log(x),6,1) ;
zplot (m)
title('SOL= x-(x - 1)^2/2+(x - 1)^3/3-(x - 1)^4/4 + (x - 1)^5/5 1')
xlabel('x')
ylabel('fx')
grid

SOL= x-(x - 1)2/2+(x - 1)3/3-(x - 1)4/4 + (x - 1)5/5 1

500
0
-500

fx

-1000
-1500
-2000
-2500
-3000
-6

-4

-2

0
x

c) taylor(sin(x),pi/2,6)
syms x
%declaracin de variable
t = taylor(sin(x),pi/2,6) ;
%DEFINION DEL VECTOR
ezplot(t)
title('SOL=(pi/2 - x)^4/24 - (pi/2 - x)^2/2 + 1')
xlabel('x')
ylabel('fx')
grid

SOL=(pi/2 - x)4/24 - (pi/2 - x)2/2 + 1


90
80
70
60

fx

50
40
30
20
10
0
-6

-4

-2

0
x

d) taylor(x^t,3,t) solucin : (t^2*log(x)^2)/2 + t*log(x) + 1


syms x t
m = taylor(x^t,3,t) ;
ezplot(m)
title('SOL=: (t^2*log(x)^2)/2 + t*log(x) + 1')
xlabel('x')
ylabel('fx')
grid

SOL=: (t 2*log(x)2)/2 + t*log(x) + 1


6

fx

-2

-4

-6
-6

-4

-2

0
x

e) x = 0:pi/100:2*pi;

1
0.8
0.6
0.4
0.2
0
-0.2
-0.4
-0.6
-0.8
-1

J = cos(x);
grid on
y2= cos(x-0.25);
y3= cos(x-0.5);
plot
Multiples grficos
1
0.8
0.6
0.4
0.2
0
-0.2
-0.4
-0.6
-0.8
-1

4
X

(x,J,x,y2,x,y3)

x = 0:pi/100:2*pi;
J = cos(x);
grid on
y2= cos(x-0.25);
y3= cos(x-0.5);
plot (x,J,'-',x,y2,'--',x,y3,':')
Multiples grficos y distintos tipos de lineas
1
0.8
0.6
0.4

0.2
0
-0.2
-0.4
-0.6
-0.8
-1

4
X

H) Define una lnea de guiones


x = -pi:pi/10:pi;
J = exp(-x).*cos(3*x);
plot (x,J,'-rs','LineWidth',1,'MarkerEdgeColor','R','MarkerFaceColor','b','MarkerSize',10)
title ('LINEA DE GUIONES CON MARCADORES CIRCULARES AZULES')
xlabel('X')
ylabel('Y')
grid on
LINEA DE GUIONES CON MARCADORES CIRCULARES AZULES
10

-5

-10

-15

-20

-25
-4

-3

-2

-1

0
X

G) AADIENDO GRAFICOS
semilogx(1:100,'+')
hold on
plot (1:3:300,1:100,'--')
title ('AADIENDO GRAFICOS')
xlabel('X')
ylabel('Y')
grid on
hold off

AADIENDO GRAFICOS
100
90
80
70

60
50
40
30
20
10
0
0
10

10

10
X

10

A= sin ([(0:pi/16:pi)' (0:pi/16:pi)'+pi/4 (0:pi/16:pi)'+pi/2 (0:pi/16:pi)'+ 3*pi/4]);


plot (A)
title (Graficando lneas de matrices de Datos)
xlabel('X')
ylabel('Y')
grid on
Graficando lneas de matrices de Datos
1
0.8
0.6
0.4

0.2
0
-0.2
-0.4
-0.6
-0.8
-1

10
X

12

14

16

18

A = sin ([(0:pi/16:pi)' (0:pi/16:pi)'+pi/4 (0:pi/16:pi)'+pi/2 (0:pi/16:pi)'+ 3*pi/4]);


J = 1:length(A);
plot (J,A,J,A+pi/8,J,A+pi/6)
title ('Graficar matrices con pares como argumentos')
xlabel('X')
ylabel('Y')
grid on

Graficar matrices con pares como argumentos


2

1.5

0.5

-0.5

-1

10
X

12

14

16

18

GRFICO DE NMEROS COMPLEJOS

plot (eig(rand(20,20)),'o','MarkerSize',6)
title ('Grfico de Nmeros complejos')
xlabel('X')
ylabel('Y')
grid on
Grfico de Nmeros complejos
1
0.8
0.6
0.4

0.2
0
-0.2
-0.4
-0.6
-0.8
-1
-2

4
X

10

LMITES DE LOS EJES


x= 0:pi/16:2*pi;
plot (x,sin(x));
title ('Lmites de los eje')
axis([o pi -1 1])
xlabel('X')
ylabel('Y')
grid on

Lmites de los eje


1
0.8
0.6
0.4
0.2
0
-0.2
-0.4
-0.6
-0.8
-1

VENTANAS DE FIGURAS Y MLTIPLES GRFICOS POR FIGURAS


t= 0:pi/20:2*pi;
[x,y] = meshgrid(t);
subplot(2,2,1)
plot (sin(t),cos(t))
title ('Ventanas de Figuras y mltiples grficos por figuras')
axis equal
subplot(2,2,2)
z= sin(x)+cos(y);
plot (t,z)
axis ([0 2*pi -2 2])
subplot(2,2,3)
z= sin(x).*cos(y);
plot (t,z)
axis ([0 2*pi -1 1])
subplot(2,2,4)
z= (sin(x).^2)-(cos(y).^2);
plot (t,z)
axis ([0 2*pi -1 1])
xlabel('X')
ylabel('Y')
grid on

Ventanas de Figuras y mltiples grficos por figuras


1
2
0.5

-0.5

-1

-1
-1

-0.5

0.5

-2

0.5

0.5

-0.5
-1

-0.5

-1

CREACIN DE GRFICOS ESPECIALIZADOS


GRFICOS DE BARRA
y= [5 8 9 5 4 ; 2 7 8 5 3 ; 1 3 6 5 2];
bar(y)
title ('Bar')
xlabel('X')
ylabel('Y')
grid on

Bar
9
8
7
6

5
4
3
2
1
0

2
X

BAR3
y= [5 8 9 5 4 ; 2 7 8 5 3 ; 1 3 6 5 2];
bar3(y)
title ('Bar3')
xlabel('X')
ylabel('Y')
grid on

Bar3

10

0
5

1
4
2

3
3

2
1

BAR3(Y,'GROUP')
y= [5 8 9 5 4 ; 2 7 8 5 3 ; 1 3 6 5 2];
bar3(y,'group')
title ('Bar3')
xlabel('X')
ylabel('Y')
grid on

Bar3
10
8
6
4
2
0
1

3
Y
X

y= [5 8 9 5 4 ; 2 7 8 5 3 ; 1 3 6 5 2];
bar(y,'stack')
title ('Bar3')
xlabel('X')
ylabel('Y')
grid on

Bar3
35

30

25

20

15

10

2
X

GRAFICAR BARRAS CON ARGUMENTO


dias=1:30;
ruido=60*rand(1,30)+45;
bar(dias,ruido)
title ('Graficar barras con argumento ')
xlabel('Dias monitoreados')
ylabel('Nivel de ruido')
grid on

Graficar barras con argumento


120

100

Nivel de ruido

80

60

40

20

10

15
20
Dias monitoreados

25

30

35

GRFICOS DE REA
y= [5 8 9 5 4 ; 1 3 6 5 2; 2 7 8 5 3];
area(y)
title ('Grficos de rea')
xlabel('X')
ylabel('Y')
grid on
Grficos de rea
35

30

25

20

15

10

1.2

1.4

1.6

1.8

2
X

2.2

2.4

2.6

2.8

HISTOGRAMAS
y = [5 8 9 5 4 ; 1 3 6 5 2; 2 7 8 5 3];
y = randn(10000,1);
hist(y)
title ('Histogramas')
xlabel('X')
ylabel('Y')
grid on
Histogramas
3000

2500

2000

1500

1000

500

0
-4

-3

-2

-1

0
X

y = [5 8 9 5 4 ; 1 3 6 5 2; 2 7 8 5 3];
ynormal = randn(10000,1);
yuniforme = randn(10000,1);
subplot(1,2,1)
hist(ynormal,30)
title ('Distribucion normal')
subplot(1,2,2)
hist(yuniforme,30)
title ('Distribucion uniforme')
xlabel('X')
ylabel('Y')
grid on

Distribucion normal

Distribucion uniforme

1000

1200

900
1000

800
700

800

600

500

600

400
400

300
200

200

100
0
-4

-2

0
-4

-2

0
X

GRFICOS POLARES
t = 0:.01:2*pi;
polar(t,sin(2*t).*cos(2*t),'--r')
title ('Grficos Polares')
xlabel('X')
ylabel('Y')
grid on

Grficos Polares
90

0.5

120

60
0.4
0.3

150

30
0.2

0.1
180

210

330

240

300
270
X

GRFICO DE DATOS DISCRETOS


STEM
alpha = .02;beta = .5;t=0:4:200;
y = exp (-alpha*t).*sin(beta*t);
stem(t,y)
title ('Stem')
xlabel('tiempo')
ylabel('amplitud')
grid on
Stem
1
0.8
0.6

amplitud

0.4
0.2
0
-0.2
-0.4
-0.6
-0.8

20

40

60

80

100
tiempo

120

140

160

180

200

STEM3
t= (0:255)/256*2*pi;
x= cos(t);
y = sin(t);
z= abs(fft(sin(t.^3)));
stem3(x,y,z)
title ('Stem3')
xlabel('eje x')
ylabel('eje y ')
zlabel ('Magnitud espectral')
grid on
Stem3

Magnitud espectral

20

15

10

0
1
0.5

1
0.5

-0.5
eje y

-0.5
-1

-1

eje x

STAIRSTEP
alpha = 0.01;
beta = 0.5;
t= 0:10;
f=exp(alpha*t).*sin(beta*t);
stairs(t,f)
title ('Stairstep')
xlabel('eje x')
ylabel('eje y ')
zlabel ('Magnitud espectral')
grid on

Stairstep
1.5

eje y

0.5

-0.5

-1

-1.5

5
eje x

10

GRFICOS VECTORIALES DE VELOCIDAD Y DIRECCIN

COMPASS
direccion = [45 90 90 45 360 335 360 270 335 270 335 335];
velocidad= [6 6 8 6 3 9 6 8 9 10 14 12];
direccionRad = direccion * pi/180;
[x,y] = pol2cart(direccionRad,velocidad);
compass(x,y)
Info = ('Velocidad y direccion de viento''Universidad Perez Rosales''3 de enero
2005''14 de Enero 2005');
text(-28,15,info)
title= ('compass ');

90

15

120

60
10

150

30
5

180

210

330

240

300
270

FEATHER
Feather
theta=90:-10:0;tetha=90:-10:0;
r=ones(size(tetha));
[u,v]=pol2cart(theta*pi/180,r);
feather(u,v)
axis equal
title= ('FEATHER ');

4
3
2
1
0
-1
-2
-3
1

10

11

EJEMPLO DE FEATHER
t=0:0.5:10;
s=0.05+i;
z=exp(-s*t);
feather(z)

0.8
0.6
0.4
0.2
0
-0.2
-0.4
-0.6
-0.8
-1

10

15

20

25

QUIVER
n=-2.0:.2:2.0;
[X,Y,Z]=peaks(n);
contour(X,Y,Z,10)
[U,V]=gradient(Z,.2);
hold on
quiver(X,Y,U,V)

2
1.5
1
0.5
0
-0.5
-1
-1.5
-2
-2

-1.5

-1

-0.5

0.5

1.5

QUIVER3
vz=10;
a=-32;
t=0:.1:1;
z=vz*t+1/2*a*t.^2;
vx=2;
x=vx*t;
vy=3;
y=vy*t;
u=gradient(x);
v=gradient(y);
w=gradient(z);
scale=0;
quiver3(x,y,z,u,v,w,scale)
view([70 18])

2
0
-2
-4
-6
-8
-10
0
1
2
3

0.5

1.5

2.5

3.5

GRFICOS DE CONTORNOS
CONTOUR Y CONTOUR3
[X,Y,Z]=peaks;
contour(X,Y,Z,20)

-1

-2

-3
-3

-2

-1

[X,Y,Z]=peaks;
contour3(X,Y,Z,20)

10

-5

-10
2
0
-2
-3

-2

-1

[X,Y,Z]=peaks;
[C,h]=contour(X,Y,Z,10);
clabel(C,h)

2.7
58 1

0.0
-1
58 1
2.7
-2 .5.252 96 99 63
8
1.4289 636
6
3 .88 81 9
--5.2174
99
0
.
0
81
.88
6
-2 .5
3
5 89
29
2
.
-1

636

1.4
28
9

1.428 9

0.0
99 6
36

81
2.75

96
22
-1 .

-2

-3
-3

0.0
99 6
36

0.09
9

-1

28 9
1.4

9
-2 .55 8
-1 .22
96

0.
09
96
36

636
99
0.0

6
63
99
0.0

2.
1.47584.0 5.4167
1 87 4
-1 .22 96 28 9

9
28
1.4

1.428 9 2.7
58 1
5.414.087
6.745 9 6 7 4

-2

-1

GRFICOS 3D

PLOT3D
t=0:pi/50:10*pi;
plot3(sin(t),cos(t),t)
axis square;grid on

40

30

20

10

0
1
0.5

1
0.5

-0.5

-0.5
-1

-1

[X,Y]=meshgrid([-2:0.1:2]);
Z=X.*exp(-X.^2-Y.^2);
plot3(X,Y,Z)
grid on

0.5

-0.5
2
1

2
1

-1

-1
-2

-2

MESH Y SURF
[X,Y]=meshgrid((-2:0.1:2));
Z=X.*esp(-X.^2-y.^2);
subplot(1,2,1)
mesh(Z)
title('funcion mesh')
subplot(1,2,2)
suft(Z)
tiltle('funcion surf')
funcion mesh

0.5

0.5

-0.5

-0.5
60

60
60

40

60

40

40
20

20
0 0

40
20

20
0 0

Surf(X,Y,Z,'Facecolor','interp',...
'EdgeColor','none',...
'FaceLighting','phong')
daspect([5 5 1])
axis tight
view(-50,30)
camlight left

0.4

0.2

-0.2

-0.4

1
0

0
-1
-2

-2

VISUALIZACIN DE VARIABLES DE DOS DIMENSIONES

[X,Y]=meshgrid(-10:.5:10);
R=sqrt(X.^2+Y.^2)+eps;
Z=sin(R).R;
mesh(X,Y,Z)

0.5

-0.5
10
5

10
5

-5

-5
-10

-10

ANIMACIONES

for t =1:50;
[X,Y]=meshgrid([-3:.1:3]);
surf (X,Y,exp(-t/6)*sin(t*(X.^2+Y.^2)),'FaceColor','interp',...
'EdgeColor','none',...
'FaceLighting','phong')
daspect([5 5 1])
axis tight
view(-50+3*t,30)
camlight left
mov(t)=getframe;
end
movie(mov,10)

0.5

-0.5

2
0

0
-2

-2

S-ar putea să vă placă și