+1 (315) 557-6473 

How to Build a Magic Formula Tire Modelling Using MATLAB

July 31, 2025
Aidan Mercer
Aidan Mercer
United States
Matlab
Aidan Mercer has over 7 years of experience in vehicle dynamics and simulation using MATLAB. He completed his Master’s degree from Clarkson University, USA.

Understanding tire behavior is one of the most critical elements in designing and simulating a high-performance Formula Student car. Whether you are focused on vehicle dynamics, control system development, or simply deciding on the best tire compound for specific conditions, having a reliable and accurate tire model is essential. The Magic Formula Tire (MF Tire) model stands out as one of the most trusted semi-empirical models for capturing tire behavior, particularly when working with detailed datasets such as those from the FSAE Tire Test Consortium (TTC).

This blog guides you step-by-step through building and implementing the Magic Formula Tire model using MATLAB. It introduces a user-friendly GUI-based tool tailored for student teams, making it easier to work with TTC datasets. You'll learn how to import raw data, process it, fit the Magic Formula parameters, and generate a usable tire model for further vehicle simulations. All tasks are performed within the MATLAB environment, making it ideal for students looking to integrate tire modeling into broader vehicle development projects. If you’re a student seeking help with MATLAB assignment tasks related to tire dynamics or vehicle modeling, this guide will also serve as a helpful reference for both academic and competitive use.

Why Tire Modeling Matters in Formula Student

Tires are the only interface between your Formula Student vehicle and the road. Whether it's acceleration, braking, or cornering, all forces must be transmitted through them. That makes understanding tire behavior essential for maximizing performance.

How to Build a Magic Formula Tire Modelling Using MATLAB

FSAE student teams can access detailed tire test data through the Tire Test Consortium, offering a solid foundation for modeling. This data allows you to create highly realistic, empirical models that can be simulated in MATLAB/Simulink or exported to other tools like ADAMS or Siemens NX.

Among the various empirical approaches available, the Magic Formula model stands out for its balance between complexity and computational efficiency. This model enables both fast real-time simulations and accurate behavior prediction across various operating conditions.

Introduction to the Magic Formula Tire Model

At its core, the Magic Formula expresses tire behavior as a non-linear equation that can be tuned with just a few parameters:

y = D * sin(C * atan(B * x - E * (B * x - atan(B * x))))

Here:

  • y is the output variable (e.g., lateral force)
  • x is the input (e.g., slip angle)
  • B, C, D, and E are parameters that define the curve shape

A more sophisticated, semi-empirical form of this model contains over 100 parameters and includes insights into real tire physics. That’s why it's widely used in motorsport and automotive simulation.

The semi-empirical model offers two major advantages:

  1. It allows extrapolation of data into unmeasured areas using similarity rules.
  2. It is accurate yet computationally efficient, suitable for real-time control and simulation.

Creating the Tool

To simplify the modeling process, an open-source tool was created as a graphical user interface (GUI) wrapped around a command-line MATLAB library. This GUI tool lets students:

  • Import and process TTC tire test data
  • Fit multiple tire force models (Fx, Fy, Mz, etc.)
  • Export the final model in formats compatible with MATLAB and external simulators

It builds on core MATLAB functions but adds ease of use through visual configuration and analysis.

Understanding the Methodology

The tool uses the MATLAB Optimization Toolbox for curve fitting, replacing lsqcurvefit with fmincon to allow nonlinear constraints. This lets users maintain parameter realism. For instance:

  • Cx > 0
  • Dx > 0
  • Ex ≤ 1

These constraints ensure physically realistic tire model parameters during the optimization process.

The fitting order follows dependencies within the model equations. Pure slip forces (Fx0, Fy0) are fitted first, followed by combined slip equations like Fx, Fy, and Mz.

Implementing the Model in MATLAB

For implementation, students can refer to the tire modeling literature such as "Tire and Vehicle Dynamics" by Pacejka. Each component of the model (like Fx0, which calculates longitudinal force) is translated into MATLAB functions.

Here’s a simplified version of a function that calculates Fx0:

function [Fx0, mux, Cx, Dx, Ex] = Fx0(p, longslip, inclangl, pressure, Fz)
FNOMIN = p.FNOMIN .* p.LFZO;
dfz = (Fz - FNOMIN) ./ FNOMIN;
dpi = (pressure - p.NOMPRES) ./ p.NOMPRES;
Cx = p.PCX1 .* p.LCX;
% ... More parameter calculations ...
Fx0 = Dx .* sin(Cx .* atan(Bx .* longslip - Ex .* (Bx .* longslip - atan(Bx .* longslip)))) + SVx;
End

Parameter naming and formulas closely follow the MF-Tyre/MF-Swift manual and literature conventions.

Building and Using the GUI

The GUI was developed using MATLAB’s custom UI component framework (not AppDesigner), allowing modular development. Although AppDesigner is used for layout mockups, the final application avoids its limitations.

The GUI supports isolated testing of each component and includes:

  • A Tire Data tab for importing TTC data
  • A Tyre Model tab for creating and saving models
  • A Tyre Analysis tab for plotting and validating the fit

Workflow Demonstration

  1. Install the App
    Download the app as a MATLAB toolbox file (.mltbx). Once installed, it appears in your App catalog.
  2. Import Tire Data
    Data should be in MAT format with SI units. The toolbox includes example datasets if you don’t have access to the TTC yet. Two types of data are essential:
    • Drive/Brake: For pure longitudinal slip
    • Cornering: For pure lateral slip
    Both are required to build a complete model.
  3. Configure and Run the Fitter
    Create a new tire model file and configure fit-modes (e.g., Fx0, Fy0). Fit these first to ensure dependencies are resolved correctly.
    Once satisfied, append the fitted parameters to your model or manually adjust them through the GUI interface.

Analyzing and Validating the Fit

Use the Tyre Analysis tab to plot your model against measured data. You can select steady-state conditions and visualize how well the model predicts tire forces.

If needed, manually tune parameters with real-time plot updates. This helps students understand how each parameter affects model behavior.

Exporting the Final Model

After successful fitting and validation, export your model in two formats:

  • TIR-file: Compatible with commercial software
  • MAT-file: Saves the model as a struct for direct use in MATLAB

Here’s an example of the TIR output:

[LONGITUDINAL_COEFFICIENTS]
PCX1 = 1.6
PDX1 = 1.2
PDX2 = -0.18232
PEX1 = -5.6295e-09

To use it in MATLAB:

[Fx, Fy] = mftyre.v62.eval(p, slipangl, longslip, inclangl, inflpres, FZW, tyreSide);

For external simulators, the TIR file integrates seamlessly with tools like Simulink, ADAMS, or Simpack.

Manual Tuning and Visualization

The GUI provides auto-refresh capabilities, enabling students to see instant changes as they tweak parameters. This interactive process is ideal for educational purposes and helps achieve a perfect data fit.

Results

Even skipping a few optional steps, the entire modeling process—from importing data to exporting the model—can be completed in under 5 minutes. The tool allows exporting either to struct (for MATLAB) or TIR (for commercial use). The evaluation function is fast enough to be used in real-time simulations.

However, some outputs like aligning moments (Mz0, Mz) are not yet supported. You can use other projects such as mfeval for full evaluation capabilities.

What’s Next

Future improvements for the tool are in the works:

  • Compatibility with older MF versions
  • Kamm-circle analysis
  • Better UI/UX features
  • Custom weighting during fitting

This roadmap ensures that the tool will evolve with student needs.

Final Thoughts

This tool simplifies the complex task of tire modeling and makes it accessible to university students working on MATLAB assignments or participating in Formula Student. It bridges the gap between theoretical knowledge and real-world application, especially when paired with FSAE tire data.

Students who explore this tool will not only be able to model tires effectively but also gain a deeper understanding of vehicle dynamics modeling in MATLAB.


Comments
No comments yet be the first one to post a comment!
Post a comment