%
% Function to fit two time constants to 
% an underdamped step response
%
%   [ tau1, tau2, sos ] = fitstep( time25, time75 )
%
% where   tau1   = first fitted time constant
%         tau2   = second fitted time constant
%         sos    = sum-of-squares
%         time25 = time at 25% of final response
%         time75 = time at 75% of final response
%
% (uses function fitstepf.m)
%
% Bob Newell, February, 1996
%
%-------------------------------------------------------
function [ tau1, tau2, sos ] = fitstep( time25, time75 )
%
global time1
global time2
global pv1
global pv2
%
time1 = time25;
time2 = time75;
pv1 = 0.25 ;
pv2 = 0.75 ;
tau = fmins( 'fitstepf', [ time25 time75 ] );
tau1 = tau(1);
tau2 = tau(2);
sos = fitstepf( tau );
disp( [ 'Time constant 1 = ' num2str( tau1 ) ] );
disp( [ 'Time constant 2 = ' num2str( tau2 ) ] );
disp( [ 'Sum-of-squares  = ' num2str( sos ) ] );
return;
%--------------------------------------------------------
