# How to create a sinusoidal bump for car in road?

23 visualizzazioni (ultimi 30 giorni)
Nguyen Hieu il 12 Feb 2023
Commentato: Nguyen Hieu il 14 Feb 2023
This equation for paper: "PID Control of a Nonlinear Half-Car Active Suspension System via Force Feedback ".
In Matlab I code:
a=0.11;%(m)
v=20; %(m/s)
lamda=5;%(m)
lf=1;
lr=1.5;
tf=second(0:20)
td=1+(lf+lr)/v
tr=tf+td
if 1<=tf <=1+(lamda/v)
td=1+(lf+lr)/v;
tr=tf+td;
wf=(a/2)*(1-cos(2*pi*(v/lamda)*tf))
wr=(a/2)*(1-cos(2*pi*(v/lamda)*tr))
else
td=0;
tr=0;
wf=0;
wr=0;
end
tf is a time function and I just want it run from 0 to 20 second and continuous ( to put it in my Simulink project). And Matlab show tf is matrix vector. Hope you guy can help me to create that sinusoidal bump. Thank you very much <3
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposta accettata

Sam Chak il 12 Feb 2023
Instead of using the If-Else statement, I took the pure math approach of describing the shapes of the road bumps.
By the way, I think there is an error in the profile, where the profile should be defined over the interval .
a = 0.11; % (m)
V = 20; % (m/s)
lambda = 5; % (m)
lf = 1;
lr = 1.5;
Tspan = 5; % Can be changed to 20 seconds
Tf = linspace(0, Tspan, 1000*Tspan+1);
T1 = 1;
T2 = T1 + lambda/V;
wf = (a/2)*(1 - cos((2*pi*V*Tf)/lambda)).*(heaviside(Tf - T1) - heaviside(Tf - T2));
Td = T1 + (lf + lr)/V;
Tr = Tf + Td;
T3 = Td + lambda/V;
wr = (a/2)*(1 - cos((2*pi*V*Tr)/lambda)).*(heaviside(Tf - Td) - heaviside(Tf - T3));
plot(Tf, wf), hold on
plot(Tf, wr, '--'), grid on
xlabel('Time, (sec)'),
annotation('textarrow', [1/5 1.45/5], [0.08/0.12 0.07/0.12], 'String', 'w_{f}')
annotation('textarrow', [2/5 1.65/5], [0.08/0.12 0.07/0.12], 'String', 'w_{r}')
##### 1 CommentoMostra -1 commenti meno recentiNascondi -1 commenti meno recenti
Nguyen Hieu il 14 Feb 2023
It works, thank you very much. I need to use this time function in my Simulink project, and it must to be a continous signal. Can you develope your code to made wf and wr to be continous signal ? Thank you again.

Accedi per commentare.

### Categorie

Scopri di più su General Applications in Help Center e File Exchange

R2016a

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by