Simulation time in Simulink goes up because of minor changes
显示 更早的评论
Hi guys, I don't know, if you can help with just this little amount of information, but i don't know how to make it more clear, so i thought i might just give it a try: i have a vehicle double-track model implemented in simulink. originally the speed was set by giving a motor torque input. i replaced that with a PID-regulator to be able to set a specific speed. the regulator actually works just fine except you can't make changes in the speed while at the same time having a steering input. This is because the part where the tire forces are limited is implemented like this:
function F_iy_max = KammKreis(F_ix, F_R_max)
%#codegen
F_iy_max = sqrt((F_R_max).^2 - F_ix.^2);
F_R_max is the maximum is calculated as the limit of adhesion, while F_ix and F_iy are the Tireforces in x- and y-direction. So when the regulator sets a high acceleration, the value under the sqrt will be negative and the result is complex, which i don't want it to be. So i tried fixing the issue by replacing the code with this code:
function F_iy_max = KammKreis(F_ix, F_R_max)
F_iy_max=zeros(1, 4)
for i=1:4
if (F_ix(i)^2)<=(F_R_max(i)^2)
F_iy_max(i)=sqrt(F_R_max(i)^2 - F_ix(i)^2)
else
F_iy_max(i)=0
end
end
after all this coede fixes the issue, but the time it takes the modell to simulate for example 300s is like 40s instead of 4s. Does anyone have a clue why this happens? Thanks in advance!
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 General Applications 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!