Question

3. In ENGR 1016, you learn how to program a small robot to perform various tasks....

3. In ENGR 1016, you learn how to program a small robot to perform various tasks. One typical task is to have your robot follow another around a track. A sensor detects the distance between the two robots. If the following robot gets too close to the lead robot, then it must slow down or stop to avoid a collision. Write a MATLAB function called SpeedControl that takes the input from the sensor (Distance) and outputs the percentage of full speed (PerSpeed) for the robot to travel based on the following: If Distance is >= 12 inches, Perspeed = 100 (full speed) If Distance is >= 9 inches and < 12 inches, PerSpeed = 75 If Distance is >= 6 inches and < 9 inches, PerSpeed = 50 If Distance is >= 3 inches and < 6 inches, PerSpeed = 25 If Distance is < 3 inches, PerSpeed = 0 (complete stop) Test your function for various Distances, and sketch a flow chart of your function.

Homework Answers

Answer #1

Matlab code

============================================================================================

function [Perspeed] = SpeedControl()
distance=input('Enter distance: ');

if(distance>=12)
Perspeed = 100;
elseif(distance>=9)
Perspeed = 75;
elseif(distance>=6)
Perspeed = 50;
elseif(distance>=3)
Perspeed = 25;
else
Perspeed = 0;
end

fprintf('PerSpeed is: %d\n',Perspeed);

end

============================================================================================

Output

============================================================================================

FLOW CHART

Know the answer?
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
Similar Questions
You will write a program that loops until the user selects 0 to exit. In the...
You will write a program that loops until the user selects 0 to exit. In the loop the user interactively selects a menu choice to compress or decompress a file. There are three menu options: Option 0: allows the user to exit the program. Option 1: allows the user to compress the specified input file and store the result in an output file. Option 2: allows the user to decompress the specified input file and store the result in an...
3/ which of the following stellar properties is the most fundamental to a star’s main-sequence and...
3/ which of the following stellar properties is the most fundamental to a star’s main-sequence and post-main sequence life? A/ temperature B/ mass C/ luminosity D/ radius 4/ Stars Moppit and Boppit orbit each other as members of a binary star system. Their period of rotation about their combined centre of mass is 10 years. The semi-major axis of Boppit’s orbit around the centre of mass is 15.25 AU. What is the combined mass of Moppit and Boppit? A/ Mmoppit...
provide 3-4 paragraphs post (team 2) 1-What are 4 key things you learned about the topic...
provide 3-4 paragraphs post (team 2) 1-What are 4 key things you learned about the topic from reading their paper? 2-How does the topic relate to you and your current or past job? 3-Critique the paper in terms of the organization and quality.1- Employee Stress and how it has an Adverse Effect on a Company This paper explores employee stress and how it has an adverse effect on a company, its employees and the organization. Job stress can have a...
How can differential analysis be applied here to determine if it would be profitable to invest...
How can differential analysis be applied here to determine if it would be profitable to invest in new equipment to increase capacity for a constrained resource? KRAYDEN’S CYCLE COMPONENTS INTRODUCTION: COMPANY, PRODUCT, AND SUPPLY CHAIN Krayden’s Cycle Components (KCC) is a high-end specialty fabricator that manufactures one product with many variants. The basic product is known as a rolling chassis, a key component used in manufacturing motorcycles. While there are variations across the industry, a rolling chassis typically consists of...
Delta airlines case study Global strategy. Describe the current global strategy and provide evidence about how...
Delta airlines case study Global strategy. Describe the current global strategy and provide evidence about how the firms resources incompetencies support the given pressures regarding costs and local responsiveness. Describe entry modes have they usually used, and whether they are appropriate for the given strategy. Any key issues in their global strategy? casestudy: Atlanta, June 17, 2014. Sea of Delta employees and their families swarmed between food trucks, amusement park booths, and entertainment venues that were scattered throughout what would...