Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please any help for this MATLAB Code would be greatly appreciated...I am totally lost. Thanks!! Problem 1 (10 pts) Lab 2 in this course involves

Please any help for this MATLAB Code would be greatly appreciated...I am totally lost. Thanks!! image text in transcribed
image text in transcribed
Problem 1 (10 pts) Lab 2 in this course involves creating a code to control a trafficlight simulator, with 4 directions (lanes) -North, East, South, and West. For this problem you will create a function that will be used for that lab, vehicleCheck. The purpose of this function is to check whether a car is present at the traffic light in either the N-S direction or the E-W direction. a) Create a function script named vehicleCheck that takes in two inputs and has one output. One input should be x, and is describing the direction of travel (0 for N-S or 1 for E-W). The other input should be carLocations, and describes roadway sensor information at the intersection. (carLocations will be input as a 1x4 vector containing 1s and 0s, where each column represents a direction [N ES W]; a "1" in a column means that a car is NOT present in that lane. The output will be y, which describes the presence or absence of a car in the direction specified by x. (1 for a car present, 0 for no car present).) b) Using the Truth Table below, write an algorithm in your function that converts the inputs and outputs shown into MATLAB code. (Hint: Start by making an if/else statement for the two possible conditions of x (0 or 1), and nest more if/else statements inside to look at the possible carLocations). Car Locations South No Car Present X Car Present Car Present No Car PresentX Direction North 0 East West Output Car Present No Car PresentX Car Present No Car Present X Car Present No Car PresentIX Car Present No Car PresentX No Car Present ar Car Present No Car Present0 X means input does not affect output. Check: Try your function with x 0 (N-S direction) and carLocations [1, 1, 0, 1]). Does your code output what you would expect? NOTE: The function and m file must be named vehicleCheck or the program will not run. If program does not run there will be serious point deductions. SAVE THIS VEHICLE CHECK CODE AND BRING IT TO LAB 2 Problem 2 (10 pts) Flowcharts are very useful for tools for visually seeing your scripts in action. They are useful for explaining your code. a) Create a flowchart for the function in Problem 1 (using PowerPoint is recommended). Use the standard flowchart symbols specified in the Lecture 12 slides

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

101 Database Exercises Text Workbook

Authors: McGraw-Hill

2nd Edition

0028007484, 978-0028007489

More Books

Students also viewed these Databases questions