KETA01 Tenta 2012-03-08 Carmen Arévalo

Contents

Uppfift 1

Ainv=[0.074505 0 0 0
0.081619 0.081619 0 0
0.080795 0.080795 0.080795 0
0 0 0 0.084767];
A=inv(Ainv)
A =
       13.422            0            0            0
      -13.422       12.252            0            0
            0      -12.252       12.377            0
            0            0            0       11.797

The inverse cannot correspond to the figure because: According to this inverse, reservoir 4 is only affected by inputs to reservoir 4, but we see in the figure that it is affected by inputs in all other reservoirs

b = [750; 150; 50; 30];
c=Ainv*b
c =
       55.879
       73.457
       76.755
        2.543

Uppgift 2

t=[0  1  4  6  8  12  16  20];
c=[12  22  32  45  58  75 70  48];
Q=18;

The coefficients in order of decreasing degree are:

p=polyfit(t,c,3)
tplot=linspace(0,20);
cplot=polyval(p,tplot);
plot(t,c,'o',tplot,cplot)
legend('data','cubic polynomial','location','best')
xlabel('time')
ylabel('concentration')
conc=@(t)p(1)*t.^3+p(2)*t.^2+p(3)*t+p(4);
format shortg
M=Q*[quad(conc,0,5);quad(conc,0,10);quad(conc,0,15);quad(conc,0,20)]
p =
    -0.023301      0.34267       4.1382       13.888
M =
       2372.5
       7231.7
        13760
        19569

Uppgift 3

V=500; Cin=0.5; F=40; k=5e-3;K=0.1;
fun=@(C)V/F+(K/k)*log(C/Cin)-(C-Cin)/k;
fun10=@(C)V/F+(K/k)*log10(C/Cin)-(C-Cin)/k;
Cplot=linspace(0.0001,6);
funplot=fun(Cplot);
plot(Cplot,funplot)
xlabel('Concentration')
ylabel('function')
grid
Cout=fzero(fun,0.5)
Cout =
      0.57679

Other alternatives

Cout10=fzero(fun10,0.5)
C=fsolve(fun,0.001)
fu=@(C)(-K/k*log(C/Cin)+1/k*(C-Cin))*F/V-1;
Cu=fzero(fu,0.5)
Cout10 =
      0.56804

Equation solved.

fsolve completed because the vector of function values is near zero
as measured by the default value of the function tolerance, and
the problem appears regular as measured by the gradient.



C =
    0.0018367
Cu =
      0.57679