Problem with if else loop
Show older comments
Hi dear, I am trying to model a car accident by analysing skid marks over a track. There is a patch of wet ice present, and the friction coefficient is give. Between 0 to 14 metres, the car is on asphalt, between 14-31m, there is a patch of ice, and 31 to 48 there is still skid marks. I think my model have some issues with executing the if statement after the 14-31m condition. How do i fix this?
for k= 2:length(t)
if s<14
a=-u*g;
u=0.7;
v(k)=v(k-1)+a*dt;
s(k)=s(k-1)+v(k)*dt;
elseif 14<s<31
u=0.12+0.07*exp(0.06*v(k-1));
a=-u*g;
v(k)=v(k-1)+a*dt;
s(k)=s(k-1)+v(k)*dt;
elseif 31<=s
u=0.7;
a=-u*g;
v(k)=v(k-1)+a*dt;
s(k)=s(k-1)+v(k)*dt;
elseif v(k)<0.0
break;
end
end
disp(v);
figure
Accepted Answer
More Answers (0)
Categories
Find more on Variables in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!