Skip to content

Instantly share code, notes, and snippets.

@RustSynx
Last active October 18, 2026 21:49
Show Gist options
  • Select an option

  • Save RustSynx/7d5e6b324f022f42ccb118d68877e800 to your computer and use it in GitHub Desktop.

Select an option

Save RustSynx/7d5e6b324f022f42ccb118d68877e800 to your computer and use it in GitHub Desktop.
clear; clc; close all;
%% 1. Parameters
ms = 250; % Sprung Mass (kg)
mu = 35; % Unsprung Mass (kg)
ks = 16000; % Suspension Spring Stiffness (N/m)
cs = 1500; % Suspension Damper Coefficient (N*s/m)
kt = 160000; % Tire Spring Stiffness (N/m)
%% 2. State-Space Matrices
A = [ 0, 1, 0, 0;
-ks/ms, -cs/ms, ks/ms, cs/ms;
0, 0, 0, 1;
ks/mu, cs/mu, -(ks+kt)/mu, -cs/mu];
B = [0; 0; 0; kt/mu];
C = [1, 0, 0, 0; % Output 1: Body (zs)
0, 0, 1, 0]; % Output 2: Wheel (zu)
D = [0; 0];
%% 2. Plotting
out = sim("quarter_car.slx");
plot(out.simout.time,out.simout.data,'LineWidth',2)
legend('Body', 'Wheel')
title('Quater Car')
xlabel('Time (s)')
ylabel('Displacement (m)')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment