You are on page 1of 1

Matlab Code

del=0.1;
time=0:del:40;
K=7.5;
tauI=10.0;
h1(1)=0;h2(1)=0;h3(1)=0;
q(1)=7.5;
for i=1:length(time)-1
h1_dot=0.275*q(i)-0.5*h1(i);
h2_dot=h1(i)-h2(i);
h3_dot=h2(i)-h3(i);
q_dot=K*((1-h3(i))/tauI + (h3(i)-h2(i)));
h1(i+1)=h1(i) + del*h1_dot;
h2(i+1)=h2(i) + del*h2_dot;
h3(i+1)=h3(i) + del*h3_dot;
q(i+1)=q(i) + del*q_dot;
end
plot(time,h3,time,q)
legend('height_t3','Flow Rate')

Plot

You might also like