Undefined function or variable 'V0'.

I am running a laptime simulation for a formula 1 car. When coding the corner speeds and times part of the simulation i keep getting V0 as an undefined variable when i can not define it with a number as that is not what the laptime simulator does. I need to know how to make the simulation run and produce its own values for V0 and other velocities without me having tom define V0 at the start.
This for a 3rd year dissertation project so any help at all would be great and i will provide any code and information i can.
Thanks in advance.
cnr = 1;
for i=1:nseg
rad = track(i,2);
if rad ~= 0
dist = track(i,1);
[cnrVel(cnr),cnrTimes(cnr)] = calcCornerSpeed(rad,dist,cz,mu,m,A,V0);
cnrNum(cnr) = i;
cnr = cnr + 1;
end
end
function [vel,t] = calcCornerSpeed(rad,dist,cz,mu,m,A,V0)
rho = 1.225;
Fz = 0.5*rho*cz*(V0.^2) + m*9.81;
vel = sqrt((rad*mu/m)*Fz);
t = dist./vel;
if (vel-V0)^2 > 0.0001
[vel,t] = calcCornerSpeed(rad,dist,cz,mu,m,A,vel);
end
end

3 个评论

According to what I understand , you have no idea what v0 value should be? Please define explicitly what the variables represent and the values. Please note description is needed. +1 to the question , I am a Formula 1 fan ;).
From a purely Matlab perspective you are passing v0 into your function without having defined it anywhere. Your function itself does not calculate v0 so it has to be provided from somewhere if you expect to use it. Where you get it from sounds more like a domain problem than a Matlab problem.
Think of it as original velocity so it is the first value of velocity that is taken into the function for the first iteration of the loop, as opposed to 'vel' which is the velocity after the loop.
The values are for drag and downforce equations
Rho = air density Cz/cd = downforce and drag coefficients A = area

请先登录,再进行评论。

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Multibody Modeling 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by