Question

MATLAB

s are applied 26. The braking distance of a car depends on its speed as the brakes are appiet and on the cars braking efficiency. A formula for the braking distance is s2 ba_2Rg where ba is the braking distance, s is the cars speed, R is the braking efficiency, and g is the acceleration due to gravity 19.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. [s, R] = promptSandR ; brakDi st = calcbd (S, R) ; printbd (brakDist)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:

promptSandR.m file

function [s,R] = promptSandR()
%asking the user to enter the s and R values
s = input('Enter speed of car(s): ');
R = input('Enter braking effeciency of car(R):');

end

calcbd.m file

function brakDist = calcbd(s, R)
g = 9.81;%gravitation due to gravity
brakDist = (s.^2)/(2*R*g);%formula to calculate breaking distance
end

printbd.m file

function [] = printbd(brakDist)
%printing the breaking distance
disp('\nBreaking Distance is: ');
disp(brakDist);
end

test.m file

[s, R] = promptSandR;
brakDist = calcbd(s,R);
printbd(brakDist);

Output:

Enter speed of car(s): 65
Enter braking effeciency of car(R):0.8

Breaking Distance is:
269.1769

Add a comment
Know the answer?
Add Answer to:
MATLAB s are applied 26. The braking distance of a car depends on its speed as...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Generate code with matlab please and thank you. The braking distance of a car depends on...

    Generate code with matlab please and thank you. 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 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). Write a a script that calls a function to prompt the user for s and R, that function call...

  • Nay programming languge is fine (MatLab, Octave, etc.) This is the whole document this last picture...

    Nay programming languge is fine (MatLab, Octave, etc.) This is the whole document this last picture i sent is the first page 5. Write and save a function Sphere Area that accepts Radius as input argument, and returns SurfaceArea (4 tt r) as output argument. Paste the function code below. Paste code here 6. Validate your Sphere Area function from the command line, checking the results against hand calculations. Paste the command line code and results below. 7. Design an...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT