Analytical vs Numerical Solution in MATLAB: Differences & Examples

Illustration
support - 2026-07-24T11:30:36+05:30
Question: Analytical vs Numerical Solution in MATLAB: Differences & Examples

What is the difference between analytical solutions (dsolve) and numerical ODE solvers (ode45) in MATLAB?

Expert Answer

Profile picture of Neeta Dsouza Neeta Dsouza answered . 2026-07-24

Analytical solutions compute exact symbolic expressions (e.g., y(t) = 5e-2t). Numerical solutions compute discrete numerical arrays approximating solution curves over time intervals.

% Differential Equation: dy/dt = -2y, y(0) = 5

% 1. Analytical Solution (Symbolic Math Toolbox)
syms y(t)
ode = diff(y,t) == -2*y;
cond = y(0) == 5;
y_exact = dsolve(ode, cond);
disp('Exact Analytical Solution:'); disp(y_exact);

% 2. Numerical Solution (ode45)
dydt = @(t,y) -2*y;
[t_num, y_num] = ode45(dydt, [0 2], 5);

plot(t_num, y_num, 'o-'); title('Numerical Solution via ODE45');


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!