% First Order System Response Demonstration
% 
% FIRSTORD  illustrates first-order measurement system responses, 
% including step response of a lumped thermal parameter model, 
% (Example 3.3), and sinusoidal forcing function response, (Example 3.6).
% The user can also specify a custom forcing function. 
% The display is set by one of five modes, selected by the popup menu 
% labeled "Input Function."
% 
% THERMAL STEP MODE (default startup mode)
% Thermal Step Mode illustrates the step response of a first-order system,
% specifically the response of a thermal system with lumped parameters 
% (small Biot number) to a step change of environment temperature
% (Example 3.3).  The editable parameters are:
% m   mass, default value 0.0008855 Kg
% c   specific heat, default value 0.1393 KJ/Kg°C
% h   film coefficient, default value 0.245 KW/m^2°C
% As  surface area, default value 7.854e-5 m^2
% Ti initial temperature, default 20 °C
% Tf  final temperature, default 37 °C
% (values for a 0.5 cm diameter mercury sphere in motionless water)
% In thermal step mode, the system response time is calculated according 
% to tau=m*c/h/As, which is displayed below the editable parameters.  The
% static sensitivity, K, of a thermal system is 1.  The display shows the 
% environment temperature in black and the system response in blue.  A 
% dashed line marks the initial slope, which achieves 100% response at 
% the response time.
% 
% RAMP MODE
% Ramp Mode shows the response of a generic first-order measurement 
% system to a ramp forcing function.  The editable parameters are:
% tau  the system response time
% K    static sensitivity
% y0   initial value
% a    slope of the ramp
% b    initial value of the ramp
% The system response to the ramp approaches an asymptote line, which in
% turn lags the ideal zero-order system response by the response time tau.
% 
% LINE SEGMENTS MODE
% In line segments mode, the forcing function is made up of the lines 
% connecting the points given in arrays t and F.  The default contents of
% t and F are:
% t=[-5:49]';
% F=[ones(1,10),2*sin(1:25),12-(1:20)]';
% The response of a generic first-order measurement system is 
% calculated numerically using the Matlab routine ODE45().  The 
% editable system parameters are:
% tau   the system response time
% K     static sensitivity
% y0    initial value
% Pushing the "Return" button returns the response to the main workspace
% variables tout and yout.  First you must select the output time basis.
% The natural output of ODE45 uses non-uniform time increments for optimum 
% accuracy and efficiency.  This is the time basis used in the display.
% You can accept this tout by pressing the "Display" button, or you can 
% specify your own uniform sampling rate by pressing the "Resample" button.
% 
% START HARMONIC MODE
% Shows the start-up transient for a generic first-order measurement
% system with a sinusoidal forcing function.  The parameters are:
% tau   the system response time
% K     static sensitivity
% y0    initial value
% A     sine amplitude
% f     sine frequency
% The response is a transient, decaying exponentially from the initial
% value to the sinusoidal asymptote.  The magnitude of the transient
% (C in Equation 3.9), is indicated.
% 
% STEADY HARMONIC MODE
% Shows the steady response of the generic first-order measurement system
% to a sinusoidal forcing function.  In this case initial value is 
% irrelevent.  The response magnitude B (Eqn. 3.9), the attenuation 
% factor M (Eqn. 3.10), and the time delay (Beta sub 1) are indicated.
% Pushing the "Freq. Response" button starts a new window where the
% attenuation factor and the phase shift functions are displayed, with
% the frequency of the forcing function marked.
% 
% FIRSTORD(t,F) starts the window in Line Segments mode, and uses
% the given columns of time t and forcing function F(t), in place of
% the default data.  The values in t must be strictly increasing.
% 
% See also FOURCOEF, FUNSPECT, DATASPECT, SECONDORD, 
% COUPLEDSYS, and SAMPLETHIS.
