%EJERCICIO 2
A=[4 -2 -10 -10;2 10 -12 32;-4 -6 16 -16];
solucion2=rref(A)
%EJERCICIO 4
 B=[0 1 -1;-6 -11 6;-6 -11 5];
 Autovalores=eig(B)
 %Autovectores
[Q D]=eig(B);Q=Q
%EJERCICIO 5
C=[(1.5-2i) (-0.35+1.2i) (30+40i);(-0.35+1.2i) (0.9-1.6i) (20+15i)];
V=rref(C);
I1=30+40i;
I2=20+15i;
S1=V(1,3)*I1
S2=V(2,3)*I2


%EJERCICIO 7
 x=[0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5];
 y=[10 10 16 24 30 38 52 68 82 96 123];
 p=polyfit(x,y,2)
 yc=polyval(p,x);
 figure(1)

plot(x,y,'x',x,yc);
xlabel('x'),ylabel('y'),grid,title('Ajuste polinomico')
legend('Datos','Ajuste polinomico',4)

%EJERCICIO 8
figure (2)
wt=0:0.05:3*pi;
v=120*sin(wt);
i=100*sin(wt-(pi/4));
subplot(2,2,1)
plot(wt,v)
hold on
plot(wt,i)
hold off
title('EJERCICIO 8.1')

subplot(2,2,2)
grid on
xlabel('x')
ylabel('y')
title('EJERCICIO 8.2')
subplot(2,2,3)
Fm=3;
fa=Fm*sin(wt);
fb=Fm*sin(wt-(2*pi/3));
fc=Fm*sin(wt-(4*pi/3));
plot(wt,fa)
hold on
plot(wt,fb)
hold on
plot(wt,fc)
hold off
grid on
xlabel('x')
ylabel('y')
title('EJERCICIO 8.3')
subplot(2,2,4)
fr=3;
tita = (0:0.01:2.01*pi);
x = fr*cos(tita);
y = fr*sin(tita);
plot(x,y,'-b')

title('EJERCICIO 8.4')
%ejercicio 11
P=[1 0 -35 50 24];
praices=roots(p)
solucion2 =

     1     0     0     2
     0     1     0     4
     0     0     1     1


Autovalores =

   -1.0000
   -2.0000
   -3.0000


Q =

    0.7071   -0.2182   -0.0921
    0.0000   -0.4364   -0.5523
    0.7071   -0.8729   -0.8285


S1 =

  -1.2960e+03 + 1.1964e+03i


S2 =

  -4.2301e+02 + 8.1466e+02i


p =

    4.0233    2.0107    9.6783


praices =

  -0.2499 + 1.5307i
  -0.2499 - 1.5307i