Contents

Ejercicio 2

A = [ 4 -2 -10; 2 10 -12; -4 -6 16]
B = [-10; 32; -16]
X = A\B
A =

     4    -2   -10
     2    10   -12
    -4    -6    16


B =

   -10
    32
   -16


X =

    2.0000
    4.0000
    1.0000

Ejercicio 4

A = [ 0 1 -1; -6 -11 6; -6 -11 5]
[V,D]=eig(A);
A =

     0     1    -1
    -6   -11     6
    -6   -11     5

Ejercicio 5

A=[ 1.5-2j -0.35+1.2j; -.35+1.2j 0.9-1.6j]
B=[ 30+40j; 20+15j]
X=A\B
A =

   1.5000 - 2.0000i  -0.3500 + 1.2000i
  -0.3500 + 1.2000i   0.9000 - 1.6000i


B =

  30.0000 +40.0000i
  20.0000 +15.0000i


X =

   3.5902 +35.0928i
   6.0155 +36.2212i

Ejercicio 6

%{
i = torre inicial
a = torre auxiliar
f = torre final
function hanoi(n,a,b,c)
if n > 0
  hanoi(n-1, a, c, b);
  fprintf('mover el disco %d de la torre %c a la torre %c\n', n, i, f);
  hanoi(n-1, b, a, c);
end
%}
hanoi(5,'1','2','3')
mover disco 1 de 1 a 3
mover disco 2 de 1 a 2
mover disco 1 de 3 a 2
mover disco 3 de 1 a 3
mover disco 1 de 2 a 1
mover disco 2 de 2 a 3
mover disco 1 de 1 a 3
mover disco 4 de 1 a 2
mover disco 1 de 3 a 2
mover disco 2 de 3 a 1
mover disco 1 de 2 a 1
mover disco 3 de 3 a 2
mover disco 1 de 1 a 3
mover disco 2 de 1 a 2
mover disco 1 de 3 a 2
mover disco 5 de 1 a 3
mover disco 1 de 2 a 1
mover disco 2 de 2 a 3
mover disco 1 de 1 a 3
mover disco 3 de 2 a 1
mover disco 1 de 3 a 2
mover disco 2 de 3 a 1
mover disco 1 de 2 a 1
mover disco 4 de 2 a 3
mover disco 1 de 1 a 3
mover disco 2 de 1 a 2
mover disco 1 de 3 a 2
mover disco 3 de 1 a 3
mover disco 1 de 2 a 1
mover disco 2 de 2 a 3
mover disco 1 de 1 a 3

Ejercicio 7

x = [0,0.5,1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0]
y = [10,10,16,24,30,38,52,68,82,96,123]
p=polyfit(x,y,2);
xx = linspace(0,6);
z = polyval(p,xx);
plot(xx,z,x,y,'ro')
x =

  Columns 1 through 7

         0    0.5000    1.0000    1.5000    2.0000    2.5000    3.0000

  Columns 8 through 11

    3.5000    4.0000    4.5000    5.0000


y =

    10    10    16    24    30    38    52    68    82    96   123

Ejercicio 11

f(x)=x^4-35x^2+50x+24

f=[1 0 -35 50 24]
r=roots(f)
f =

     1     0   -35    50    24


r =

   -6.4910
    4.8706
    2.0000
   -0.3796

Ejercicio 12

%{
function ecdif
[t, yy] = ode45(@HalfSine, [0 35], [1 0], [], 0.15);
plot(t, yy(:,1))

function y = HalfSine(t, y, z)
h = sin(pi*t/5).*(t<=5);
y = [y(2); -2*z*y(2)-y(1)+h];
%}
ecdif

Ejercicio 14

v = imread('WindTunnel.jpg', 'jpeg');
v(250:330, 100:180, 1) = 255;
v(250:330, 100:180, 2) = 0;
v(250:330, 100:180, 3) = 0;
image(v)
figure
row=200;
red = v(row, :, 1);
gr  = v(row, :, 2);
bl  = v(row, :, 3);
plot(red, 'r');
hold on
plot(gr, 'g');
plot(bl, 'b')