The braking distance of a car depends on its speed as the brakes
are applied and on the car’s braking efficiency. A formula for the
braking distance is
bd =s^2/ 2Rg
where bd is the braking distance, s is the car’s speed, R is the braking efficiency and g is
the acceleration due to gravity (9.81). A script has been written that calls a function to
prompt the user for s and R, calls another function to calculate the braking distance, and
calls a third function to print the braking distance in a sentence format with one decimal
place. You are to write a function stub for the function that prompts for s and R, and the
actual function definitions for the other two functions.
Ch6Ex26.m
[s, R] = promptSandR;
brakDist = calcbd(s, R);
printbd(brakDist)
promptSandR.m
function [s, R] = promptSandR
s = 33;
R = 11;
end
calcbd.m
function bd = calcbd(s, R)
bd = s .^ 2 / (2*R*9.81);
end
printbd.m
function printbd(bd)
fprintf('The braking distance was %.1f\n', bd)
end
need an explanation for this answer? contact us directly to get an explanation for this answer