How to create a sinusoidal bump for car in road?

25 次查看(过去 30 天)
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

采纳的回答

Sam Chak
Sam Chak 2023-2-12
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)'),
ylabel('Road Disturbance, w (m)')
title('Road Profiles')
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 个评论
Nguyen Hieu
Nguyen Hieu 2023-2-14
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Multibody Modeling 的更多信息

产品


版本

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by