Professional Documents
Culture Documents
Solved: Write A User-Defined MATLAB Function, With Two Input An...
Solved: Write A User-Defined MATLAB Function, With Two Input An...
home / study / engineering / electrical engineering / control theory / control theory solutions manuals / matlab / 4th edition / chapter 7
The fuel efficiency of an automobile is measured in mi/gal (miles per U.S. gallon) or in km/L (kilometers per liter). Write a
MATLAB user-defined function that converts fuel efficiency values from km/L to mi/gal. For the function name and
arguments use mpg=kml TOmpg(kml). The input argument kml is the efficiency in km/L, and the output argument mpg is
the efficiency in mi/gal. Use the function in the Command Window to:
(a) Determine the fuel efficiency in mi/gal of a car that consumes 9 km/L.
(b) Determine the fuel efficiency in mi/gal of a car that consumes 14 km/L.
MATLAB
(4th Edition) Edit edition
Step-by-step solution:
71%(14 ratings)
for this chapter’s solutions
Step 2 of 4
The following is the MATLAB user-defined function that converts fuel efficiency values from km/L to mi/gal:
%This user defined function is used to convert fuel efficiency values from km/L to ml/gal
function mpg=kmlTOmpg(kml)
mpg=kml*2.35214583;
Step 3 of 4
Run the MATLAB user-defined function kmlTOmpg.m by typing the following command in the MATLAB command
window:
>> mpg=kmlTOmpg(9)
mpg =
21.1693
Step 4 of 4
(b)
Run the MATLAB user-defined function kmlTOmpg.m by typing the following command in the MATLAB command
window:
>> mpg=kmlTOmpg(14)
mpg =
32.9300
Back to top
Corresponding Textbook
Rent | Buy
1P 2P 3P 4P 5P
6P 7P 8P 9P 10P
Back to top
ABOUT CHEGG LEGAL & POLICIES CHEGG PRODUCTS AND SERVICES CHEGG NETWORK CUSTOMER SERVICE
Become a Tutor Advertising Choices Cheap Textbooks Online Tutoring EasyBib Customer Service
Chegg For Good Cookie Notice Chegg Coupon Sell Textbooks Internships.com Give Us Feedback
College Marketing General Policies Chegg Play Solutions Manual Studyblue Help with Chegg Tutors
Corporate Development Intellectual Property Rights Chegg Study Help Study 101 Thinkful Help with eTextbooks
Investor Relations Terms of Use College Textbooks Test Prep Help to use EasyBib Plus
Jobs Chegg Tutors Terms of Service eTextbooks Textbook Rental Manage Chegg Study
Join Our Affiliate Program Global Privacy Policy Chegg Math Solver Used Textbooks Subscription
Media Center DO NOT SELL MY INFO Mobile Apps Digital Access Codes Return Your Books