Engineers should be familiar with the units and dimensions of various quantities in the common systems...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Engineers should be familiar with the units and dimensions of various quantities in the common systems of units such as metric, imperial, SI, etc. You are required to write a program in a function file HW6P2.m that converts either the pressure or the temperature from current units to the desired units. The function definition line will be function HW6P2 (S_PorT, Val, S_CU, S_DU) Where S_Port is a string indicating the type of the quantity ('P' or 'p' for pressure and 'T' or 't' for temperature). Val is the numerical value of a quantity in the current units. S_CU is a string of the current units and S_DU is a string of the desired units. • The available units of the pressure is either 'kPa', 'bar', 'psi', 'atm' or 'torr'. Where (kPa is the kilo Pascal, psi is the pound per square inch, atm is atmosphere and torr is mm of mercury.) • The available units for the temperature is either 'C', 'F', 'K', or 'R'. (C is for degree Celsius, F for degree Fahrenheit, K for Kelvin and R for Rankine.) 1. (4 pts) The function must use a main switch-case structure to switch between pressure conversion, temperature conversion or otherwise. If the string assigned to S_PorT as the function is called is any other character than ('P', 'p', 'T' or 't'), the function must call the MATLAB built-in error() function in the otherwise branch to display the message "The quantity entered is unrecognized, please enter P or p for pressure and T or t for temperature". See the help text of the error function by typing doc error at the command prompt. 2. If the string S_PorT is recognized the function proceed to the branch of either the pressure or the temperature of the main switch-case structure where the following is done in each of the temperature and the pressure branches: a. (7 pts) in a nested switch-case structure, if the string assigned to S_CU is recognized by the function, the function must convert the quantity entered from the current units to its value in a common units. For example, change everything to bar for pressure and everything to R for temperature. Otherwise, if S_CU is not recognized by the function, the function in the otherwise branch of th nested switch-case must call the error() function to display a message "Current units entered is unrecognized." b. (7 pts) in another switch-case structure nested in the same branch (P or T) as the previous one, if the string assigned to S_DU is recognized by the function, the function must convert the quantity in the common units calculated in the previous nested switch-case structure to its value in the desired units. Otherwise, if S_DU is not recognized by the function, the function in the otherwise branch of this nested switch-case must call the error() function to display a message "Error: The Units entered is not recognized." 3. (2 pts)After the end of the main switch-case structure, the function must use fprintf() to display the output in the format: >> HW6P2 ( 'P', 300, 'kPa', 'psi') 200 kPa 29 psi >> HW6P2 ('t', 300, 'K', 'F') 300 K 80.33 F 4. Conversions: a. 1 bar = 100 kPa = 14.5 psi = 750 torr = 0.9868 atm b. 1 R = 1 F +459.67 = 1 C (9/5) + 491.67 = 1 K (9/5) 5. Test your function for each of following cases: a. HW6P2('E', 300, 'K', 'F') b. HW6P2('P', 200, 'kPa', 'psi'), HW6P2('p', 20, 'psi', 'torr') c. HW6P2("T", 300, 'K', 'F'), HW6P2('t', 30, 'C', 'R') d. HW6P2('P', 300, 'K', 'F'), HW6P2("T", 200, 'kPa', 'psi') e. HW6P2('t', 300, 'kJ', 'F'), HW6P2('T', 300, 'F', 'mps') f. HW6P2('p', 300, 'PSI', 'psi'), HW6P2('p', 300, 'bar', 'gal') Engineers should be familiar with the units and dimensions of various quantities in the common systems of units such as metric, imperial, SI, etc. You are required to write a program in a function file HW6P2.m that converts either the pressure or the temperature from current units to the desired units. The function definition line will be function HW6P2 (S_PorT, Val, S_CU, S_DU) Where S_Port is a string indicating the type of the quantity ('P' or 'p' for pressure and 'T' or 't' for temperature). Val is the numerical value of a quantity in the current units. S_CU is a string of the current units and S_DU is a string of the desired units. • The available units of the pressure is either 'kPa', 'bar', 'psi', 'atm' or 'torr'. Where (kPa is the kilo Pascal, psi is the pound per square inch, atm is atmosphere and torr is mm of mercury.) • The available units for the temperature is either 'C', 'F', 'K', or 'R'. (C is for degree Celsius, F for degree Fahrenheit, K for Kelvin and R for Rankine.) 1. (4 pts) The function must use a main switch-case structure to switch between pressure conversion, temperature conversion or otherwise. If the string assigned to S_PorT as the function is called is any other character than ('P', 'p', 'T' or 't'), the function must call the MATLAB built-in error() function in the otherwise branch to display the message "The quantity entered is unrecognized, please enter P or p for pressure and T or t for temperature". See the help text of the error function by typing doc error at the command prompt. 2. If the string S_PorT is recognized the function proceed to the branch of either the pressure or the temperature of the main switch-case structure where the following is done in each of the temperature and the pressure branches: a. (7 pts) in a nested switch-case structure, if the string assigned to S_CU is recognized by the function, the function must convert the quantity entered from the current units to its value in a common units. For example, change everything to bar for pressure and everything to R for temperature. Otherwise, if S_CU is not recognized by the function, the function in the otherwise branch of th nested switch-case must call the error() function to display a message "Current units entered is unrecognized." b. (7 pts) in another switch-case structure nested in the same branch (P or T) as the previous one, if the string assigned to S_DU is recognized by the function, the function must convert the quantity in the common units calculated in the previous nested switch-case structure to its value in the desired units. Otherwise, if S_DU is not recognized by the function, the function in the otherwise branch of this nested switch-case must call the error() function to display a message "Error: The Units entered is not recognized." 3. (2 pts)After the end of the main switch-case structure, the function must use fprintf() to display the output in the format: >> HW6P2 ( 'P', 300, 'kPa', 'psi') 200 kPa 29 psi >> HW6P2 ('t', 300, 'K', 'F') 300 K 80.33 F 4. Conversions: a. 1 bar = 100 kPa = 14.5 psi = 750 torr = 0.9868 atm b. 1 R = 1 F +459.67 = 1 C (9/5) + 491.67 = 1 K (9/5) 5. Test your function for each of following cases: a. HW6P2('E', 300, 'K', 'F') b. HW6P2('P', 200, 'kPa', 'psi'), HW6P2('p', 20, 'psi', 'torr') c. HW6P2("T", 300, 'K', 'F'), HW6P2('t', 30, 'C', 'R') d. HW6P2('P', 300, 'K', 'F'), HW6P2("T", 200, 'kPa', 'psi') e. HW6P2('t', 300, 'kJ', 'F'), HW6P2('T', 300, 'F', 'mps') f. HW6P2('p', 300, 'PSI', 'psi'), HW6P2('p', 300, 'bar', 'gal')
Expert Answer:
Answer rating: 100% (QA)
HW6P2m function HW6P2 SPorT Val SCU SDU Matlab function that converts either the pressure or the temperature from current units to the desired units Inputs SPorT string containing the unit for convers... View the full answer
Related Book For
Fundamentals of Heat and Mass Transfer
ISBN: 978-0471457282
6th Edition
Authors: Incropera, Dewitt, Bergman, Lavine
Posted Date:
Students also viewed these mathematics questions
-
T F T F T F T F T F T T T T T T T T T T Use the given sequence to determine the values of n1 n2, the number of runs G, and the 5% cutoff values from Table A-10.
-
A gas at p = 50 kPa and T = 300 K has a mass density of 0.0802 kg/m 3 . a. Identify the gas. b. What is the rms speed of the atoms in this gas? c. What is the mean free path of the atoms in the gas?
-
A gas mixture at 300 K and 200 kPa consists of 1 kg of CO2 and 3 kg of CH4. Determine the partial pressure of each gas and the apparent molar mass of the gas mixture.
-
State the density property of a barometer liquid and explain its effects. Explain in detailed.
-
In Learning-By-Doing Exercise 10.1 we examined the effects of an excise tax of $6 per unit. Repeat that exercise for an excise tax of $3.
-
A man and his wife decide that they will keep having children until they have one of each sex. Ignoring the possibility of twins and supposing that each trial is independent and results in a boy or a...
-
With reference to the \(n=50\) interrequest time observations in Example 6, Chapter 2, which have mean 11,795 and standard deviation 14,056, what can one assert with \(95 \%\) confidence about the...
-
William H. Bailey, MD, executed a note payable to California Dreamstreet, a joint venture that solicited investments for a cattle breeding operation. Baileys promissory note read, Dr. William H....
-
Need absolute coordinates for cad drawing below 10 5.0 5.0 4.0 10.0 8.0- 3.0 2.0 1.0- 0.5 10.0 2.0 45 4.0 3.0 9.6 www.myCADsite.com 7.0
-
Which series has the highest beta. BraveNewCoin Liquid Index for Bitcoin 1D BNC Trading Brave Ne Yellow Green Blue Orange
-
Accounting is considered the language of business, and also applies in our personal financial lives. Cost is determined by fixed and variable. The difference variable expenses differ from fixed...
-
An annuity provides for 10 annual payments. The first payment of 1,000 is made immediately and the remaining payments increase by 6% per year. Interest is calculated at 5% per year. Calculate the...
-
IT soybean oil drops $.10, what is the equity of the account when marked-to-market? You are day-trading the S&P E-Mini contract with $5,250.00 of equity in your account. Contract specs are as...
-
Employee retention contributes to the stability and success of your business. It costs a lot of time, finances, and exertion to hire new employees and train them, and turnover can hinder the firm's...
-
What would the proposed sales tax percentage paid at the register for USED Goods?
-
Warren Buffett is perhaps the most successful investor of all times. His qualitative and quantitative analysis of financial information is the source of his success. This video was PBS's "Buffett and...
-
Given any inner product (,) on a vector space, we can define a norm by ||x|| = (x, x) 1/2. The converse is not true, i.e., there are norms that are not induced by an inner product. Show that the...
-
Listed below are common types of current liabilities, contingencies, and commitments: a. Accounts payable b. Bank loans and commercial paper c. Notes payable d. Dividends payable e. Sales and excise...
-
A computer code is being developed to analyze a 12.5-mm-diameter, cylindrical sensor used to determine ambient air temperature. The sensor experiences free convection while positioned horizontally in...
-
An oil pre-heater consists of a ingle tube of 10 mm diameter and 5m length, with its surface maintained at 175C by swirling combustion gases. The engine oil (new) enters at 75C. What flow rate must...
-
The spectral emissivity of an opaque, diffuse surface is as shown. (a) If the surface is maintained at 1000 K, what is the total, hemispherical emissivity? (b) What is the total, hemispherical...
-
The dividend yield is the: A. Dividends paid per ordinary share. B. The proportion of the return in one year on a share. C. The profit per share. D. The dividend on a share as a proportion of the...
-
The per share element of the EPS calculation includes: A. All shares. B. The average number of ordinary shares outstanding during the year. C. The number of ordinary shares outstanding at the end of...
-
The best case study of all is probably the real-world situation. This allows you to: choose situations that are topical; choose countries that you are both knowledgeable about and interested in; ...
Study smarter with the SolutionInn App