Problem 3 A highway manager has asked for help programming a
Problem 3 A highway manager has asked for help programming a highway
advisory sign. A digital wind gage will provide a wind gust speed to the device
which will display the appropriate restriction. In order to test the device a function
program is required which uses if statements and prints to the screen, (fprintf) the
appropriate restriction as shown below.
Wind Speed Restriction
Gusts <20 mph | 55 mph speed limit
Gusts 20<35 mph | 40 mph speed limit
Gusts 35<45 mph | 40 mph speed limit; Bridge closed to pedestrians, bicycles, and buses.
Gusts 45<50 mph | 35 mph speed limit; Bridge closed to vehicles with trailers, roof rack items and motorcycles.
Gusts 50< 65 mph | 30mph speed limit; Bridge closed to all vehicles except cars.
Gusts > 65 mph | Bridge closed to all traffic.
The first line of your function should be function [ ]= HW3_P3(windgust)
This is a MATLAB question. Please show the function you created! Thank you!
Solution
the matlab code shall be as follows:
function [ ]= HW3_P3(windgust)
 if windgust<20
 fprintf(\'55 mph speed limit\');
 else if windgust<35
 fprintf(\'40 mph speed limit\');
 else if windgust<45
 fprintf(\'40 mph speed limit; Bridge closed to pedestrians, bicycles, and buses\');
 else if windgust <50
 fprintf(\'35 mph speed limit; Bridge closed to vehicles with trailers, roof rack items and motorcycles\');
 else if windgust<65
 fprintf(\'30mph speed limit; Bridge closed to all vehicles except cars\');
 else
 fprintf(\'Bridge closed to all traffic\');
 end
 end
 end
 end
 end
 end

