this code gives me the results are wrong slip ratio and abs activity is 0 and the velocity is constant 100 fix ti

clc;
clearvars;

% Simulation parameters
timeStep = 0.01;
simulationDuration = 20; % seconds
numberOfSteps = simulationDuration / timeStep;

% Initial conditions
vehicleSpeed = 100 / 3.6; % 100 km/h to m/s
wheelRadius = 0.3;
wheelAngularSpeed = vehicleSpeed / wheelRadius; % Angular speed of the wheel (rad/s)
brakePressure = 0; % No braking at the start
normalLoad = 4000; % Normal force in Newtons
vehicleMass = 1500; % Vehicle mass in kg
wheelRadius = 0.3; % Wheel radius in meters
wheelInertia = 3; % Assumed wheel inertia (kg m^2) - placeholder value

% Create storage for data
timeVector = (0 : numberOfSteps - 1) * timeStep;
brakePressureHistory = zeros(1, numberOfSteps);
wheelSpeedHistory = zeros(1, numberOfSteps);
vehicleSpeedHistory = zeros(1, numberOfSteps);
slipRatioHistory = zeros(1, numberOfSteps);
longitudinalForceHistory = zeros(1, numberOfSteps);
isABSActiveHistory = zeros(1, numberOfSteps);

% Braking System Parameters
maxBrakePressure = 10e6; % Maximum possible braking pressure (Pascals)
pressureRampUpTime = 5; % Time in seconds to reach max brake pressure
pressureRampStep = maxBrakePressure / (pressureRampUpTime / timeStep); % Pressure increment per time step

% Tire Parameters
mu_max = 0.8; % Maximum friction coefficient - placeholder value

% ABS System Parameters
CONTROL = 0; % Variable to decide whether to increase or decrease pressure
absDropPressure = 5e5; % Pressure drop per cycle when ABS is active

for step = 1:numberOfSteps
    currentTime = step * timeStep;
    
    % Apply brake pressure dynamically
    brakePressure = Ramp(maxBrakePressure, 0, currentTime, brakePressure, CONTROL);

    % Calculate slip ratio
    current_wheel_speed = wheelAngularSpeed * wheelRadius;
    slip_ratio = slip(current_wheel_speed, vehicleSpeed);
    
    % Calculate tire forces using the tire model
    longitudinal_force = tiremodel(slip_ratio, normalLoad, mu_max);
    
    % Calculate braking torque from brake pressure
    % Assume front brakes generate 70% of the total braking force and rear 30%
    frontBrakeForce = 0.7 * longitudinal_force;
    rearBrakeForce = 0.3 * longitudinal_force;
    
    brakingTorque = (frontBrakeForce + rearBrakeForce) * wheelRadius; % Total braking torque
    
    % Update wheel angular speed based on the braking torque (simplified wheel dynamics)
    angularDeceleration = brakingTorque / wheelInertia;
    wheelAngularSpeed = max(wheelAngularSpeed - angularDeceleration * timeStep, 0);
    
    % Update vehicle speed based on the total longitudinal force
    vehicleDeceleration = longitudinal_force / vehicleMass;
    vehicleSpeed = max(vehicleSpeed - vehicleDeceleration * timeStep, 0);
    
    % ABS Control Logic
    if abs(slip_ratio) > 0.2 % Simple activation threshold
        % If the ABS system activates, it causes a reduction in brake pressure,
        % trying to reduce wheel lock-up and maintain control.
        CONTROL = -1;
        isABSActive = 1;
    else
        CONTROL = 1; % Increase brake pressure gradually
        isABSActive = 0;
    end
    
    % Adjust brake pressure based on ABS control
    brakePressure = Ramp(maxBrakePressure, 0, currentTime, brakePressure, CONTROL);

    % Store data for post-processing
    brakePressureHistory(step) = brakePressure;
    wheelSpeedHistory(step) = wheelAngularSpeed * wheelRadius;
    vehicleSpeedHistory(step) = vehicleSpeed;
    slipRatioHistory(step) = slip_ratio;
    longitudinalForceHistory(step) = longitudinal_force;
    isABSActiveHistory(step) = isABSActive;
end

% Post-processing: plot results
subplot(4,1,1);
plot(timeVector, vehicleSpeedHistory * 3.6);
xlabel("Time (s)"); ylabel("Vehicle Speed (km/h)");
title("Vehicle Speed vs. Time");

subplot(4,1,2);
plot(timeVector, wheelSpeedHistory * 3.6);
xlabel("Time (s)"); ylabel("Wheel Speed (km/h)");
title("Wheel Speed vs. Time");

subplot(4,1,3);
plot(timeVector, slipRatioHistory);
xlabel("Time (s)"); ylabel("Slip Ratio");
title("Slip Ratio vs. Time");

subplot(4,1,4);
plot(timeVector, isABSActiveHistory);
xlabel("Time (s)"); ylabel("ABS Active (0 or 1)");
title("ABS Activity vs. Time");

linkaxes(findall(gcf,"type","axes"), "x");

these are my functions

function [T_f, T_r] = Braking_torque(Pl, Af, Ar, mu_f, mu_r, N_f, Rmean_f, Rmean_r)
% Friction forces at the front and rear tires
FRIC_F = Pl * Af * mu_f * N_f;
FRIC_R = Pl * Ar * mu_r * N_f;

% Braking torques at the front and rear tires
T_f = FRIC_F * Rmean_f;
T_r = FRIC_R * Rmean_r;
end

function [PL_RAMP] = Ramp(PL, PL_0, T1, PL_PRE, CONTROL)
% Define the step size for changing the pressure
PLINE_STEP = 0.2;

% Set initial pressure if simulation just started
if T1 == 0
    PL_RAMP = PL_0;
else
    % Adjust pressure based on control flag
    PL_RAMP = PL_PRE + CONTROL * PLINE_STEP;
    
    % Bound pressure to not exceed maximum or go below zero
    PL_RAMP = min(max(PL_RAMP, 0), PL);
end
end

function [slip_ratio] = slip(wheel_speed, vehicle_speed)
    if vehicle_speed > 0
        slip_ratio = (vehicle_speed - wheel_speed) / vehicle_speed;
    else
        slip_ratio = 0;
    end
end

function [control] = ABScycle(a1, a2, a3, a4, aw, aw_pre)
% Determine the direction of change in angular acceleration
delta_aw = aw - aw_pre;

% ABS control logic to determine brake pressure adjustment
if aw < 0 % Decelerating wheel
    if aw > a1 && delta_aw < 0
        control = 1; % Increase brake pressure
    elseif aw <= a1 && delta_aw < 0
        control = -1; % Decrease brake pressure
    else
        control = 0; % Hold brake pressure
    end
else % Accelerating wheel or steady state
    if aw <= a4 
        control = 0; % Hold brake pressure
    else
        control = 1; % Increase brake pressure
    end
end
end

function [FX] = tiremodel(slip_ratio, normal_load, mu_max)
    % Pacejka tire coefficients - these values are placeholders
    B = 10; % Stiffness factor
    C = 1.9; % Shape factor
    D = mu_max * normal_load; % Peak value
    E = 0.97; % Curvature factor
    
    % Calculate the normalized slip ratio (input to the Pacejka formula)
    slip_normalized = abs(slip_ratio);
    
    % Calculate the longitudinal force using the simplified Pacejka ‘Magic Formula’
    Fx_normalized = D * sin(C * atan(B * slip_normalized - E * (B * slip_normalized - atan(B * slip_normalized))));
    
    % Check if we are in the linear or saturation region of the tire curve
    if slip_normalized < 1
        FX = Fx_normalized;
    else
        FX = D; % Tires in full sliding produce force dependent on mu_max and normal_load only
    end
end