1.9 Obtain Laplace transform for a piecewise functions

Problem: Obtain the Laplace transform for the function defined in the following figure.

pict

Function f(t) to obtain its Laplace transform

Comment: Mathematica solution was easier than Matlab’s. In Matlab the definition of the Laplace transform is applied to each piece separately and the result added. Not finding the piecewise maple function to access from inside MATLAB did not help.

Mathematica

Remove["Global`*"]; 
f[t_] := Piecewise[{{0,t<0}, 
                    {t,t>= 0 && t< T}, 
                    {T, t>T}}] 
Simplify[LaplaceTransform[f[t],t,s] ,{T>0}]
 

Out[]= (1 - E^((-s)*T))/s^2
 

 

Matlab

clear all; 
syms T t s; 
syms s positive; 
I1 = int(t*exp(-s*t),t,0,T); 
I2 = int(T*exp(-s*t),t,T,Inf); 
result = simple(I1+I2); 
pretty(result)
 

  1 - exp(-T s) 
  ------------- 
        2 
       s
 

 

Maple

With Maple, had to use Heaviside else Laplace will not obtain the transform of a piecewise function.

restart; 
assume(T>0): 
interface(showassumed=0): 
f:=t->piecewise(t<0,0,t>=0 and t<T,t,t>T,T): 
r:=convert(f(t),Heaviside): 
r:=inttrans[laplace](r,t,s);
 

\[ {\frac {1-{{e}^{-sT}}}{{s}^{2}}} \]