Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

MATLAB QUESTION At the entrance to the Brooklyn-Battery tunnel, all trucks and v

ID: 3860874 • Letter: M

Question

MATLAB QUESTION

At the entrance to the Brooklyn-Battery tunnel, all trucks and vans must be visually inspected by police. A van inspection takes 1 minute whereas a truck inspection takes two minutes. If there are two inspection lanes (two inspections can happen at the same time) and 60% of the vehicles coming thru the inspection are vans (40% are trucks), how many total vehicles can be inspected in an hour? You may not restrict trucks or vans to either lane, it is a single entry lane leading to two independent inspection stations. (hint: you want to use a while loop)

Explanation / Answer

function [TotalInspectedVehicles] = CalculateNumberOfVehiclesInspected(Minutes)
%This function calculates the number of vehicles inspected in given minutes

   TotalVansInspected = CalculateNumberOfVehicleTypeInspected(Minutes,0.6,1,2);
   TotalTrucksInspected = CalculateNumberOfVehicleTypeInspected(Minutes,0.4,2,2);
   TotalInspectedVehicles = TotalVansInspected + TotalTrucksInspected;
  
   printf(" ");
   printf(" TOTAL VANS INSPECTED IN 60 MINUTES IS %d", TotalVansInspected );
   printf(" TOTAL TRUCKS INSPECTED IN 60 MINUTES IS %d", TotalTrucksInspected );
   printf(" ----------------------------------------------");
    printf(" TOTAL VEHICLES INSPECTED IN 60 MINUTES IS %d", TotalInspectedVehicles );
    printf(" ----------------------------------------------");
    printf(" ");
  
end

function [TotalInspectedVehiclesPerTypeInAllLanes] = CalculateNumberOfVehicleTypeInspected(TotalMinutes,PercentageOfTotalVehiclesInspectedNormally,TotalNumberOfMinutesTakenToInspectVehicleType,TotalLanesAvailable)

   NumberOfMinutesForVehicleType= TotalMinutes * PercentageOfTotalVehiclesInspectedNormally;

   TotalVehicleTypeInspected = NumberOfMinutesForVehicleType/TotalNumberOfMinutesTakenToInspectVehicleType;

   TotalInspectedVehiclesPerTypeInAllLanes = TotalLanesAvailable * TotalVehicleTypeInspected;

end

%call the function to know how many vehicles are inspected
%in 60 minutes across two lanes

CalculateNumberOfVehiclesInspected(60);

%--------------------------------------------------end of code

code shared at:

https://drive.google.com/open?id=0B0-Ll2y6vo_sb2lQakh6aFhqdWs

https://goo.gl/G4YYVR

The above code assumes that vehicles are coming through every minute.

In case this is not true and you are looking for a real time inspection software, then more functions or logic needs to be written. High level logic to implement such real time scenario is mentioned below.

you will need a Timer object to run a function for 60 minutes. The function randomly sets flag everytime lanes are checked for vehicle (you will either need a random number generating utility function or run parallely another function to take input from user everytime a vehicle gets through). 0 would mean a vehicle has got through. 1 means vehicle has not got through.

Everytime a vehicle gets through, 60% has to be allocated to van and 40% to truck on a minute basis (you will need a specific formula). After 60 minutes, the timer function will stop and you will have total vehicles that have gone through in 60 minutes.

If I manage to write the additional code, then I will post it in comments later or edit this answer.