A highway manager has asked for help programming a highway a
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, (f print f the appropriate restriction as shown below. The first line of your function should be function [] = Hw3_P3(windgust)
Solution
Matlab code:
function[] = HW3_P3(windgust)
if(windgust < 20)
fprintf(\'55 mph speed limit\ \');
elseif(windgust >= 20 & windgust < 35)
fprintf(\'40 mph speed limit\ \');
elseif(windgust >= 35 & windgust < 45)
fprintf(\'40 mph speed limit \ Bridge closed to pedistrians bicycles and buses\ \');
elseif(windgust >= 45 & windgust < 50)
fprintf(\'35 mph speed limit \ Bridge closed to vehicles with trailers roof rack items and motorcycles\ \');
elseif(windgust >= 50 & windgust < 65)
fprintf(\'30mph speed limit! \ Bridge closed to all vehicles except cars\ \');
else
fprintf(\'Bridge closed to all traffic\ \');
end
end
