Introduction: The Art of Reading Between the Lines
Here’s a scenario that every engineer encounters: You have data. Maybe it’s temperature readings from a sensor every hour. Maybe it’s stock prices at the close of each trading day. Maybe it’s the deflection of a beam at discrete points along its length. The data is discrete — it exists only at specific points — but nature (or the market) doesn’t work in discrete jumps. Between your data points, something is happening. The temperature at 2:30 PM matters, even if you only measured at 2:00 and 3:00.
This is the fundamental problem that interpolation and curve fitting solve. Interpolation asks: “Given these discrete data points, what’s the most reasonable value at a point between them?” Curve fitting asks a deeper question: “What’s the underlying pattern or relationship that generated this data?”
These aren’t just mathematical parlor tricks. They’re essential tools in every engineer’s toolkit. You’ll use interpolation to:
- Fill in missing sensor data
- Resample signals to a different rate
- Create smooth animations from keyframes
- Estimate values between calibration points
And you’ll use curve fitting to:
- Find trends in noisy data
- Calibrate sensors
- Model physical systems
- Make predictions
In this article, we’re going to dive deep into both topics. We’ll explore not just how to use MATLAB’s interp1, polyfit, and related functions, but why they work, when they fail, and how to choose the right method for your specific problem. We’ll encounter fascinating mathematical phenomena like Runge’s phenomenon (why high-degree polynomials can explode), and we’ll develop intuition for the trade-offs between smoothness, accuracy, and computational cost.
Why Numerical Methods Matter in Engineering
Let me start with a philosophical point that’s easy to miss when you’re focused on syntax and function calls. Numerical methods aren’t just “approximate math” — they’re the bridge between the continuous world of physics and the discrete world of computers.
Think about it: The equations of physics are continuous. Maxwell’s equations, the Navier-Stokes equations, Newton’s laws — they describe fields and motions that exist at every point in space and time. But when we simulate these equations on a computer, we can only represent values at discrete points. The gap between those points? That’s where numerical methods live.
A Concrete Example: The Temperature Sensor
Imagine you’re monitoring the temperature in a chemical reactor. Your sensor takes readings every 10 seconds. At t=0s, the temperature is 25°C. At t=10s, it’s 27°C. At t=20s, it’s 30°C.
Now, a reasonable question: What was the temperature at t=15s?
If you only have the data, you can’t know for certain. Maybe it was 28.5°C (linear interpolation). Maybe it was 28.7°C (the true physical trajectory). Maybe there was a spike to 35°C at t=12s that you missed entirely (aliasing — a topic for another article).
This is the essence of numerical methods: making reasonable estimates in the face of incomplete information. The estimates are only as good as your assumptions. Linear interpolation assumes the temperature changed at a constant rate. Spline interpolation assumes a smoother trajectory. The “right” assumption depends on the physics of your system.
The Dangers of Blind Numerical Methods
Before we dive into the how-to, let me share a cautionary tale. In the 1970s, engineers at NASA were fitting a curve to some test data on rocket nozzle performance. They used a high-degree polynomial (because “more terms = better fit,” right?). The polynomial fit the data beautifully — perfect R², tiny residuals.
But when they used that polynomial to predict performance outside their data range (extrapolation), it went completely off the rails, predicting negative efficiencies and impossible temperatures. The high-degree polynomial was oscillating wildly between data points — a phenomenon we now call Runge’s phenomenon.
The lesson: Numerical methods are powerful, but they’re not magic. A curve that fits your data perfectly can still be completely wrong. We’ll explore why this happens and how to avoid it.



