function tr=risetime(num,den)
% RISETIME - Rise time of a continuous-time linear system.
% Step response
[yc,xc,t1]=step(num,den);
n=length(t1);
% Get more time instants for more precise picture
dt=0.005*t1(n);
t=0:dt:t1(n);
[yc,xc]=step(num,den,t);
n=length(t);
% Steady state output value
yss=yc(n);
% 10 and 90 percent of yss
delt01=0.1*yss;
delt09=0.9*yss;
for i=1:n;
    yst(i)=yss;
    y10(i)=delt01;
    y90(i)=delt09;
end;
i=1;
while (yc(i)<delt01);
    i=i+1;
end;
t01=t(i)
while (yc(i)<delt09);
    i=i+1;
end;
t09=t(i)
tr=t09-t01;
hold off
plot(t,yc,'-',t,y10,':',t,y90,':',t,yst,':')
hold on;
t1=[t01 t01];
v01=[0 delt01];
t9=[t09 t09];
v09=[0 delt09];
plot(t1,v01,':')
plot(t9,v09,':')
%text(t01+0.1,0.1,'tr01')
%text(t09+0.1,0.1,'tr09')
xlabel('t [sec]')
ylabel('y')

% Rise time
disp('Rise time (in [s]) of the system:')
printsys(num,den)
disp('is:')
