%
%   LPTDEMO.M   Demo of how to take Laplace Transforms with Matlab
%
%   This file illustrates some simple uses of the Laplace Transform capability 
%   within the Symbolic Toolbox in Matlab.
%   
%   In particular, given a short list of common time domain functions, f(t), we 
%   generate their associated Laplace transforms.  
%
%   In the following examples,
%      t - time domain independent variable
%      s - Laplace domain independent variable
%    a,b,c - constants
%
%   File written by J. R. White, UMass-Lowell (Feb. 1998)
%

%
%   getting started
      clear all,   close all
      syms a b c t s
%
%   let's define a set of time domain functions (these are symbolic variables)
      f1 = c;                     f2 = c*t;   
      f3 = exp(-a*t);             f4 = t*exp(-a*t);
      f5 = c-exp(-a*t);           f6 = (c-a*t)*exp(-a*t);
      f7 = exp(-a*t)-exp(-b*t);   f8 = -a*exp(-a*t)+b*exp(-b*t);
      f9 = sin(b*t);              f10 = cos(b*t);
      f11 = sinh(b*t);            f12 = cosh(b*t);
      f13 = exp(-a*t)*cos(b*t);   f14 = exp(-a*t)*sin(b*t);
%
%   now let's create the Laplace transforms for these functions
      F1 = laplace(f1,t,s);     F1 = simple(F1);
      F2 = laplace(f2,t,s);     F2 = simple(F2);
      F3 = laplace(f3,t,s);     F3 = simple(F3);
      F4 = laplace(f4,t,s);     F4 = simple(F4);
      F5 = laplace(f5,t,s);     F5 = simple(F5);
      F6 = laplace(f6,t,s);     F6 = simple(F6);
      F7 = laplace(f7,t,s);     F7 = simple(F7);
      F8 = laplace(f8,t,s);     F8 = simple(F8);
      F9 = laplace(f9,t,s);     F9 = simple(F9);
      F10 = laplace(f10,t,s);   F10 = simple(F10);
      F11 = laplace(f11,t,s);   F11 = simple(F11);
      F12 = laplace(f12,t,s);   F12 = simple(F12);
      F13 = laplace(f13,t,s);   F13 = simple(F13);
      F14 = laplace(f14,t,s);   F14 = simple(F14);
%
%   now let's create a short table of Laplace transform pairs
      fprintf(1,'            Table of Commom Laplace Transforms  \n\n')
      fprintf(1,'        f(t) \t\t\t             F(s) \n')
      fprintf(1,'   f1 = %s   \t\t\t       F1 = %s  \n',char(f1),char(F1))
      fprintf(1,'   f2 = %s   \t\t\t       F2 = %s  \n',char(f2),char(F2))
      fprintf(1,'   f3 = %s   \t\t       F3 = %s  \n',char(f3),char(F3))
      fprintf(1,'   f4 = %s   \t\t       F4 = %s  \n',char(f4),char(F4))
      fprintf(1,'   f5 = %s   \t\t       F5 = %s  \n',char(f5),char(F5))
      fprintf(1,'   f6 = %s   \t       F6 = %s  \n',char(f6),char(F6))
      fprintf(1,'   f7 = %s   \t       F7 = %s  \n',char(f7),char(F7))
      fprintf(1,'   f8 = %s       F8 = %s  \n',char(f8),char(F8))
      fprintf(1,'   f9 = %s   \t\t       F9 = %s  \n',char(f9),char(F9))
      fprintf(1,'   f10 = %s  \t\t       F10 = %s  \n',char(f10),char(F10))
      fprintf(1,'   f11 = %s  \t\t       F11 = %s  \n',char(f11),char(F11))
      fprintf(1,'   f12 = %s  \t\t       F12 = %s  \n',char(f12),char(F12))
      fprintf(1,'   f13 = %s            F13 = %s  \n',char(f13),char(F13))
      fprintf(1,'   f14 = %s            F14 = %s  \n',char(f14),char(F14))
%
%   To evaluate these functions for specific values, we simply substitute
%   specific constants for the symbolic variables (a, b, and c).
%
%   For example, if a = 2 and b = 3, f14 and F14 become:
      f14s = subs(f14,{a,b},{2,3});  F14s = subs(F14,{a,b},{2,3});
      fprintf(1,'\n')
      fprintf(1,'   For a = 2 and b = 3, the last entry becomes: \n')
      fprintf(1,'   f14s = %s           F14s = %s  \n',char(f14s),char(F14s))
%
%   end of program
%