Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The energy unit conversion problem solved in lecture using the MATLAB switch-case- end structure is shown below (with very few modifications): Sample Problem: Energy Unit

image text in transcribed
The energy unit conversion problem solved in lecture using the MATLAB switch-case- end structure is shown below (with very few modifications): Sample Problem: Energy Unit Conversion Ein = input('Enter the value of the energy (work) to be converted: '); EinUnits = input('Enter the current units (J, ft-lbf, or cal); ', 's'); EoutUnits = input ('Enter the new units (J, ft-lbf, or cal): ', 's') errorin = 0; errorout = 0; switch EinUnits case 'J' EJ = Bin; case ft-lbf' EJ = Ein/0.738; case 'cal' EJ = Ein/0.239; otherwise errorin = 1; end switch EoutUnits case J' Eout = EJ; case ft-lbf' Eout = EJ*0.738; case 'cal' Eout = EJ*0.239; otherwise errorout = 1; end if errorin disp('ERROR: Current units are typed incorrectly.') elseif errorout disp(ERROR: New units are typed incorrectly.') else fprintf('E = %g %s ', Eout, EoutUnits) end Imagine that you run the program above twice and you type the inputs shown below (in boldface) into the MATLAB Command Window. Write the output of the program to the Command Window in the spaces provided below (you don't need a calculator). a) Enter the value of the energy (work) to be converted: 738 Enter the current units (J, ft-lbf, or cal): ft-lbf Enter the new units (J, ft-lbf, or cal): cal b) Enter the value of the energy (work) to be converted: 239: Enter the current units (J, ft-lbf, or cal): CAL Enter the new units (J, ft-lbf, or oal): J

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Records And Database Management

Authors: Jeffrey R Stewart Ed D, Judith S Greene, Judith A Hickey

4th Edition

0070614741, 9780070614741

More Books

Students also viewed these Databases questions