ejercicios_control1-matlab

9
EJERCICIOS 1.- Evaluar la operaciones de adición, multiplicación, división, hallar las raíces, 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 = 8 b = 20 c = 20.8517 d = 27 x1 = 2 x2 = 1 na = 3 nb = 7.3891 Nx = 1.0000 NumBin =

Upload: kelvin-ibanez-silva

Post on 15-Nov-2015

3 views

Category:

Documents


0 download

TRANSCRIPT

EJERCICIOS1.- Evaluar la operaciones de adicin, multiplicacin, divisin, hallar las races, polinomios (poner los ejemplos)

a=3+5b=5*4c=3+4*7-2*sqrt(1+5^2)+exp(-3)d=3^3x1=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 = 8

b = 20

c = 20.8517

d = 27

x1 = 2

x2 = 1

na = 3

nb = 7.3891

Nx = 1.0000

NumBin =

1111

Name Size Bytes Class Attributes

NumBin 1x4 8 char Nx 1x1 8 double a 1x1 8 double b 1x1 8 double c 1x1 8 double d 1x1 8 double na 1x1 8 double nb 1x1 8 double x1 1x1 8 double x2 1x1 8 double

2.-Crear la Funcin fun_xa que evalue la serief(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);endfprintf('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 Wfunction 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,'*')gridtitle('grafica de y=x^2')xlabel('x')ylabel('y')

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 rojo 'r', (t,A) en azul 'b', (t,-A) sigue en azullegend('desplazamiento','amplitud')title('Oscilaciones amortiguadas')xlabel('t')ylabel('x')

x=linspace(0,4*pi,60);y=sin(x);z=cos(x);figure(1)plot(x,y,x,2*y.*z,'--')figure(2)plot(x,y,x,z,'*')xlabel('Variable independiente x')ylabel('Variables dependientes')

Figure1

Figure2

x=linspace(0,4*pi,60);y=sin(x);z=cos(x);a=2*sin(x).*cos(x);b=sin(x)./(cos(x)+eps);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 derechaplot(x,z), axis ([0 4*pi -1 1]), title('cos(x)')subplot(2,2,3) % selecciona la subgrfica inferior izquierdaplot(x,a), axis ([0 4*pi -1 1]), title('2sin(x)cos(x)')subplot(2,2,4) % selecciona la subgrfica inferior derechaplot(x,b), axis ([0 4*pi -40 40]), title('tg=sin(x)/cos(x)')

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'),gridfigure(2)plot3(x,y,t,'b'),gridfigure(3)plot3(x,z,t,'g'),grid

firure1

Firure2

Firure3

6.- Poner ejemplos de operaciones vectoriales

u=[1,2,3];v=[4,5,6];u+vans = 5 7 9

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

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

x=[0,0.38,0.71,0.92,1.00,0.92,0.71,0.38,0];[xmax, nmax]=max(x)xmax = 1nmax = 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 3.6000 16.0000 99.0000 9.0000 20.0000