Laplace Transform Differential Equations in MATLAB Programming

MATLAB Illustration

The Laplace Transform is a fundamental mathematical tool for analyzing dynamic systems in control engineering, electrical circuits, and mechanical vibrations. It converts time-domain differential equations into algebraic equations in the complex frequency domain ((s)-domain), making complex system responses significantly easier to solve.

In MATLAB, the Symbolic Math Toolbox allows you to perform Laplace transforms, solve for the (s)-domain transfer function, and apply the inverse Laplace transform to obtain exact time-domain analytical solutions using laplace(), ilaplace(), and solve().

Mathematical Foundation of the Laplace Transform

The Laplace transform converts a time-domain function (f(t)) into its (s)-domain equivalent (F(s)):

[F(s) = mathcal{L}{f(t)} = int_{0}^{infty} e^{-st} f(t) , dt]

Using this transformation, time derivatives convert into algebraic terms involving initial conditions:

[mathcal{L}{f'(t)} = s F(s) - f(0)] [mathcal{L}{f''(t)} = s^2 F(s) - s f(0) - f'(0)]

Step-by-Step Examples

Example 1: Solving a First-Order Linear Differential Equation

Consider the first-order differential equation:

[frac{dy(t)}{dt} + 3y(t) = 6 quad text{with initial condition } y(0) = 2]
MATLAB
syms y(t) s  % Define equation and symbolic Laplace representation Dy = diff(y, t);
eqn = Dy + 3*y == 6;
% Take Laplace transform of the equation Y = laplace(y, t, s);
eqnLaplace = laplace(eqn, t, s);
% Substitute symbolic Laplace term and initial condition y(0) = 2 eqnLaplace = subs(eqnLaplace, laplace(y, t, s), Y);
eqnLaplace = subs(eqnLaplace, y(0), 2);
% Solve for Y(s) in Laplace domain Y_s = solve(eqnLaplace, Y);
% Compute inverse Laplace transform to get y(t) y_t = ilaplace(Y_s, s, t)

Output:

MATLAB
y_t = 2 + 2*exp(-3*t)

This result shows an exponential decay settling toward a steady-state value of 2.

Example 2: Solving a Second-Order Differential Equation

Solve the second-order homogeneous differential equation:

[y''(t) + 5y'(t) + 6y(t) = 0 quad text{with } y(0) = 1, ; y'(0) = 0]
MATLAB
syms y(t) s  % Define derivatives and differential equation Dy = diff(y, t);
D2y = diff(y, t, 2);
eqn = D2y + 5*Dy + 6*y == 0;
% Transform equation to s-domain Y = laplace(y, t, s);
eqnLap = laplace(eqn, t, s);
% Substitute initial conditions y(0) = 1 and y'(0) = 0 eqnLap = subs(eqnLap, laplace(y, t, s), Y);
eqnLap = subs(eqnLap, y(0), 1);
eqnLap = subs(eqnLap, subs(diff(y, t), t, 0), 0);
% Solve for Y(s) and compute inverse Laplace transform Y_s = solve(eqnLap, Y);
y_t = ilaplace(Y_s, s, t)

Output:

MATLAB
y_t = 3*exp(-2*t) - 2*exp(-3*t)

Plotting System Response in MATLAB

Visualize the resulting time-domain analytical solution over a 5-second window using fplot():

MATLAB
figure;
f
plot(y_t, [0, 5], 'LineWidth', 1.5, 'Color', 'b');
title('Response of Second-Order System y(t)');
xlabel('Time t (seconds)');
ylabel('Amplitude y(t)');
grid on;

Key Summary

  • Use laplace() to convert time-domain differential equations into algebraic (s)-domain expressions.
  • Use subs() to inject physical initial conditions (y(0)) and (y'(0)).
  • Use solve() to isolate (Y(s)) algebraically.
  • Use ilaplace() to convert the solved (s)-domain expression back to a time-domain equation (y(t)).
  • Use fplot() to visualize transient and steady-state time responses.
Verified Feedback

What Engineering Students Say

Real feedback from students across top engineering universities worldwide.

Verified Student

“I got full marks on my MATLAB DSP assignment! The filter design code was completely vectorized, the frequency response plots were exact, and the delivery was 8 hours before my deadline. Highly recommended!”

AS

Aditi Sharma

IIT Bombay • Signal Processing Coursework
Verified Student

“Our Simulink EV powertrain model had severe algebraic loop and solver errors. The MATLABSolutions team fixed the solver configuration in 4 hours and provided an annotated scope diagram. Lifesaver for my final year!”

JM

John M.

Monash University, Australia • Simulink Dynamic Model
Technical Knowledge Base

Latest MATLAB Guides & Tutorials

Explore deep-dive technical articles written by our engineering team to master complex MATLAB & Simulink topics.

MATLAB Guide 5 Min Read

Physics-Informed Neural Networks (PINNs) for Microgrid Dynamics and Power Flow in MATLAB

Modern microgrids operate with low physical inertia, rapid inverter switching dynamics, and intermittent renewable power generation. Simulating these systems requir...

MATLAB Guide 5 Min Read

ROS 2 and MATLAB Co-Simulation for Autonomous Mobile Robot Path Tracking Using NMPC

Tracking complex trajectories with non-holonomic mobile robots requires handling physical constraints such as actuator saturation, wheel slip, and sharp cornering. Standard cont...