Vous êtes sur la page 1sur 2

Cdigo MatLab

clc
clear all
syms tau1 tau2

datos =[0 0
1 4.682436
2 8.744961
3 12.82542
4 14.69022
5 16.71238
6 17.48221
7 17.92025
8 18.19075
9 18.23363
10 18.20436];

t=datos(:,1);
h=datos(:,2);
plot(t,h,'o','linewidth',3)

K=0.0022775;
M=8000;
A1=400; %cm2
diam2=20;
h1ss=8.00;
h2ss=18.22;

e=0;
for i = 1:length(datos)
hest(i) = K*M*(1-((tau1*exp(-t(i)/tau1))-tau2*exp(-t(i)/tau2))/(tau1-
tau2));
e = e+(h(i)-hest(i))^2;
end

grad_e = transpose(jacobian(e,[tau1,tau2]));
hess_e = jacobian(grad_e,[tau1,tau2]);

x0 = [3.574;0.1052];
error=1;

while error > 0.00001


grad_ex0 = subs(grad_e,[tau1,tau2],[x0(1),x0(2)]);
hess_ex0 = subs(hess_e,[tau1,tau2],[x0(1),x0(2)]);
grad_1=double(grad_ex0);
hess_1=double(hess_ex0);
xn = x0-inv(hess_1)*grad_1;
dif1=abs(xn(2)-x0(2));
dif2=abs(xn(1)-x0(1));
error=dif1+dif2
x0=xn;
end
tau1=x0(1)
tau2=x0(2)
Cv1=A1/(tau1*0.5*h1ss^-0.5)
Cv2=(3.1416*diam2^2/4)/(tau2*0.5*h2ss^-0.5)
zeta=(tau1+tau2)/(2*(tau1*tau2)^0.5)
tau=(tau1*tau2)^0.5
wn=1/tau
ermin=0;

tt=0:1:11;
hh=K*M*(1-((tau1*exp(-tt/tau1))-tau2*exp(-tt/tau2))/(tau1-tau2));
hold on
plot (tt,hh,'c-', 'LineWidth',2)

y1 = K*M*(1 - exp(-(zeta - (zeta^2 - 1)^(1/2))*wn.*tt));


hold on
plot(tt,y1,'m','linewidth',2);
legend('Datos','Segundo Orden','Primer Orden')

Vous aimerez peut-être aussi