Main Content

Model a Road Profile with Varying Elevation and Friction

This example shows how to vary road conditions throughout a simulation of a 4-wheel drive vehicle test-bed. The model is a version of the Four-Wheel Drive Testbed that is updated to include Road Profile blocks for both the front and rear tires. As the vehicle travels, the axle parameters and the position of the center of gravity (CG) determine the position of the front and rear axles. The Road Profile blocks use the axle positions to determine vehicle angle and tire friction coefficients based on parameters that you specify.

Updates to the Original Model

The original model determines the magic formula coefficients based on the position of the vehicle relative to its position at the simulation start. The figures show the original and the updated models.

The new model includes Road Profile blocks for both the right- and left-side tires. To open the model, at the MATLAB command prompt, enter


In both models, the front, rear, and center differentials are represented by variant subsystems.

The front and rear tire subsystems contain Tire (Magic Formula) blocks, while the Vehicle Body subsystem is a mask for a Vehicle Body block.

Updates that allow the model to determine road conditions using the Road Profile blocks are:

  1. Replacement of the Road subsystem with the Wheel Position subsystem. The road subsystem contains three levels of subsystems that the model uses to determine the Magic Formula coefficients for the tires during simulation.

    The addition of the Road Profile blocks allows for the replacement of the Wheel Position system with the much simpler Wheel Position subsystem. The new subsystem demuxes the wheel position signals.

  2. Parameterization for the added Road Profile blocks for the right and left tires:


    • Horizontal distance from CG to front axlex_f

    • Horizontal distance from CG to rear axlex_r

    • Horizontal distance for vertical profilex_height_vector

    • Vertical profileheight_vector


    • Friction outputPhysical signal Magic Formula coefficients

    • Horizontal distance for friction profilex_friction_vector

    • Magic Formula coefficients for front axleMF_M_matrix

    • Magic Formula coefficients for front axleMR_M_matrix

    Position Variable

    • Override — select

    • Beginning Valuex_0

  3. Vehicle Body block Main parameter updates:

    • Horizontal distance from CG to front axlex_f

    • Horizontal distance from CG to rear axlex_r

  4. Variable definitions for the model:

    x_height_vector=[-10, 0, 10];
    height_vector=[0, 0, 0.25];
    x_friction_vector = [ -10, 5, 10, 15 ];
    MF_M_matrix = [10  1.9  1     0.97;...
                   4   2    0.1   1;...
                   12  2.3  0.82  1;...
                   10  1.9  1     0.97];
    MR_M_matrix = [10  1.9  1     0.97;...
                   12  2.3  0.82  1;...
                   12  2.3  0.82  1;...
                   10  1.9  1     0.97];
    x_0 = 0;

  5. Additional environmental updates:

    • The left-tire Road Profile block introduces a variable road grade. The Gain block converts the grade variable, beta from radians to degrees.

    • A headwind is included by using a nonzero value for the Constant block.

  6. Signal block updates:

    • Outports and Inports blocks are replaced with Connection Port blocks.

    • Goto and From blocks are used to relay signals to the Scope.

  7. Data visualization and logging updates:

    • The Scope block is updated to show tire positions, Magic Formula Coefficients, headwind, and road elevation.

    • The simlog name is updated to match the name of the updated model.

    • The differential test and plot generation code is updated to use the new simlog name.

Run the Simulation

  1. To run the simulation and generate a plot of the results, click Plot speeds.

    The front tires experience slip in the middle of the simulation due to the slippery conditions related to the [4 2 0.1 1] Magic Coefficients that the simulation uses when the positions of the front tires are 5 to 10 meters from the original positions.

  2. To see how the road incline, headwind, tire position, and vehicle speed and position relate to each other and to the Magic Coefficients, open the Scope block.

    The vehicle velocity increases slightly as the road grade decreases.

  3. To test the front and rear differentials in both the Open and Torsen variants, click Test front, rear differential.

    The Torsen differential configuration results in higher velocity throughout the simulation.

  4. To test all variants of the center differential, click Test center differential.

    The open and viscous differential configurations result in lower, more variable velocity when the grade changes during the simulation.

See Also

| | | |