Sei sulla pagina 1di 8

EJERCICIOS

1.- Evaluar la operaciones de adicin, multiplicacin, divisin,


hallar las races, polinomios (poner los ejemplos)

a=3+5
b=5*4
c=3+4*7-2*sqrt(1+5^2)+exp(-3)
d=3^3
x1=sin(pi/2)+cos(2*pi)
x2=sin(90*pi/180)
na=log10(1000)
nb=exp(2)
Nx=log(2.71828182845905)
NumBin=dec2bin(15)
whos
>>op_mat
a =

b =
20
c =

20.8517

d =
27
x1 =

x2 =
1
na =

nb =
7.3891
Nx =

1.0000

NumBin =
1111

Name

Size

Bytes

Class

Attributes

NumBin
Nx
a
b
c
d
na
nb
x1
x2

1x4
1x1
1x1
1x1
1x1
1x1
1x1
1x1
1x1
1x1

8
8
8
8
8
8
8
8
8
8

char
double
double
double
double
double
double
double
double
double

2.-Crear la Funcin fun_xa que evalue la serie


f(x) = 1 + s + x^2/2! + x^3/3! + +x^n/n!
function R =fun_xa(n,x)
n=input('ingrese el valor de n:');
x=input('ingrese el valor de x:');
R=0;
for i=0:n
R=R+x^(i)/factorial(i);
end
fprintf('el valor de la funcion es:',R)
end

3.- Crear una funcin para hallar la impedancia de un ckto. serie


RLC serie, datos R,,L,C y W
function Z=ckt_serie(R,L,C,W)
clc;
R=input('ingrese el valor de la resistencia del circuito:');
L=input('ingrese el valor de la bobina:');
C=input('ingrese el valor del condensador:');
f=input('ingrese la frecuencia:');
W=2*pi*f;
Xl=W*L;
Xc=1/(W*C);
Z=sqrt(R^2+(Xl-Xc)^2);
fprintf('la impedancia del circuito es:',Z)

4.- Poner ejemplos de grficos bidimensionales

clear all;
x=0:0.1:3;
y=x.^2;
plot(x,y,'*')
grid
title('grafica de y=x^2')
xlabel('x')
ylabel('y')

grafica de y=x 2

9
8
7
6

5
4
3
2
1
0

0.5

1.5
x

t=linspace(0,0.5,100);
x=5*exp(-7*t).*sin(100*t+1.5);
A=5*exp(-7*t);
plot(t,x,'r',t,A,'b',t,-A) % (t,x) en
(t,-A) sigue en azul
legend('desplazamiento','amplitud')
title('Oscilaciones amortiguadas')
xlabel('t')
ylabel('x')

2.5

rojo 'r', (t,A) en azul 'b',

Oscilaciones amortiguadas

desplazamiento
amplitud

4
3
2

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

0.05

0.1

x=linspace(0,4*pi,60);
y=sin(x);
z=cos(x);
figure(1)

0.15

0.2

0.25
t

0.3

0.35

0.4

0.45

0.5

plot(x,y,x,2*y.*z,'--')
figure(2)
plot(x,y,x,z,'*')
xlabel('Variable independiente x')
ylabel('Variables dependientes')
Figure1
1
0.8
0.6
0.4
0.2
0
-0.2
-0.4
-0.6
-0.8
-1

10

12

14

Figure2
1
0.8

Variables dependientes

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

x=linspace(0,4*pi,60);
y=sin(x);
z=cos(x);
a=2*sin(x).*cos(x);
b=sin(x)./(cos(x)+eps);

6
8
Variable independiente x

10

12

14

subplot(2,2,1) % selecciona la subgrfica superior izquierda.


plot(x,y), axis ([0 4*pi -1 1]), title('sin(x)')
subplot(2,2,2) % selecciona la subgrfica superior derecha
plot(x,z), axis ([0 4*pi -1 1]), title('cos(x)')
subplot(2,2,3) % selecciona la subgrfica inferior izquierda
plot(x,a), axis ([0 4*pi -1 1]), title('2sin(x)cos(x)')
subplot(2,2,4) % selecciona la subgrfica inferior derecha
plot(x,b), axis ([0 4*pi -40 40]), title('tg=sin(x)/cos(x)')
sin(x)

1
0.5

0.5

-0.5

-0.5

-1

10

2sin(x)cos(x)

-1

20

-0.5

-20
0

10

-40

10

tg=sin(x)/cos(x)

40

0.5

-1

cos(x)

10

5.- Poner ejemplos de grficos tridimensionales

t = linspace(0, 2*pi, 200);


a = 10; b = 1.0; c = 0.3;
x = b*cos(t);
y = b*sin(t);
z = c*cos(a*t);
figure(1)
plot3(x, y, z,'r'),grid
figure(2)
plot3(x,y,t,'b'),grid
figure(3)
plot3(x,z,t,'g'),grid

firure1

0.4
0.2
0
-0.2
-0.4
1
0.5
0
-0.5
-1

-1

-0.5

0.5

Firure2

8
6
4
2
0
1
0.5
0
-0.5
-1

-1

Firure3

-0.5

0.5

8
6
4
2
0
0.4
0.2
0
-0.2
-0.4

-1

-0.5

0.5

6.- Poner ejemplos de operaciones vectoriales

u=[1,2,3];
v=[4,5,6];
u+v
ans =
5

x=[4 9 16 25];
u=sqrt(x)
u =
2
3
3*u-2
ans =
4
7

x=[0,1,-1,2,-3,4];
y=2*x.^2-3
y =
-3
-1
-1

10

13

15

29

x=[0,0.38,0.71,0.92,1.00,0.92,0.71,0.38,0];
[xmax, nmax]=max(x)
xmax =
1
nmax =
5
>> x(5)
ans =
1

7.-Poner ejemplo de operaciones matriciales.

>> a=[2 .5;1 3];b=[2 1;.5 3]; %Declaracin de las matrices.

>> a+b
ans =
4.0000
1.5000

1.5000
6.0000

A=[0.1 0.3 0.3;2 3 9;2 4 1];


>> B=[2 3;1 1;1 10];
>> A*B
ans =
0.8000
16.0000
9.0000

3.6000
99.0000
20.0000

Potrebbero piacerti anche