Engineering Homework Help

EGR 150 University of Alabama at Birmingham Matlab Codes

 

EGR 150

Homework A3_HW (MATLAB)

1.(20 points)Write a script “A3_HW_1.m” which converts 250 miles to km

2.(20 points)Write an external function “KmToMiles.m” for km-to-miles conversion, which takes an input argument in km and outputs a value in miles

3.(30 points)Write a script “A3_HW_2.m”, which prompts the user to enter a value in km(e.g., 500 km) using theinput function, calculates distance in miles using your externalfunction “KmToMiles.m”, and prints the distance in miles using thedisp function

4.(30 points)Write a script “A3_HW_3.m”, which assigns a variable representing a distancea value of 650 km, converts the distance to miles using a customlocal function “MilesToKmLocal.m” , and calculates the cost of trip assuming a gasoline consumption rate of 28 miles per gallon and a gasoline cost of $1.85/gallon. Your script should print out the distance in miles and the trip cost with 2 digits after the decimal point using the fprintf function