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

MATLAB 5. The fuel consumption of an airplane is measured in gal/mi (gallon per

ID: 3722030 • Letter: M

Question

MATLAB

5. The fuel consumption of an airplane is measured in gal/mi (gallon per mile or in L/km (liter per kilometers). Write a MATLAB user-defined function that converts fuel efficiency consumption from gal/mi to L/km. For the function name and arguments, use Lkm- LkmToGalm(gmi). The input argument gmi is the consumption in gal/mi, and the output argument Lkm is the consumption in L/km. Use the function in the Command Window to: (a) Determine the fuel consumption in Lkm of a Boeing 747 whose fuel consumption is about 5 galmi. (b) Determine the fuel consumption in L/km of the Concorde whose fuel consumption is about 5.8 gal/mi

Explanation / Answer

PLEASE REFER BELOW CODE

1) CREATE FILE LkmToGalm.m AND PASTE BELOW CODE

function Lkm = LkmToGalm(gmi)

% 1 gallon = 3.78541178 liters

%1 mile = 0.62137 x km

% 1 gallon/mile = (3.78541178 * 0.62137) litres/km

Lkm = gmi * (3.78541178 * 0.62137); %using above formula

end

2) NOW FROM COMMAND WINDOW EXECUTE BELOW COMMANDS TO CALL FUNCTION

>> Lkm = LkmToGalm(5)

Lkm =

11.7607

>> Lkm = LkmToGalm(5.8)

Lkm=

13.6424