Question: MATLAB Looking for how to start this problem in Matlab. Most car models report two numbers for fuel economy--one for highway driving and one for
MATLAB
Looking for how to start this problem in Matlab.
Most car models report two numbers for fuel economy--one for highway driving and one for city driving. For this analysis, let's assume that in the city, your car gets 20 miles per gallon, and on the highway, your car gets 26 miles per gallon. Assume the gas price is $3 per gallon.
Write a function (M-file) in MATLAB called Fuel_economy that calculates the cost of gas per week based on the percentage of time you drive in the city/on highways.
The first line of your function should look like this:
function cost_of_gas=Fuel_economy(percent_highway, number_of_miles_driven, gasprice)
To test your function, assume that you drive in the city for 30% of the time, and the highway for 70% of the time. Assume you drive 100 miles per week. What is the cost of gasoline for the week?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
