{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

HW5_Campos_Tyler

# HW5_Campos_Tyler - 14W-CF HW5 Campos Tyler Wednesday 12:38...

This preview shows pages 1–2. Sign up to view the full content.

Scholar: HW5 Problem 1 Problem: Create a MATLAB program which will allow the user to input an unknown number of temperature readings, each of which might be a temperature in Celsius, Fahrenheit, Kelvin, or Rankine, and will convert the user input temperature to each of the other temperature scales. The program should request the units of the input temperature from the user, accepting the units as the character ‘C’, ‘F’, ‘K’, or ‘R’. The program must accept only valid temperature units (upper case ‘C’, ‘F’, R’, or ‘K’). The program will store the input and equivalent temperatures in vectors, using one vector for each temperature scale. You may assume the user will always enter a temperature above absolute zero. The program will average the temperatures for each scale, storing the four values in a single vector. Output from the program will be a properly labeled table including: data number (e.g., 1,2,3..), the temperature in C, F, K and R. In the last row of the table the program will output the average temperature for each scale. Diagram : NA Solution: Flowchart Start Initialize variablescel , Tcel, far, Tfar, kel, Tkel, ran, Tran, n, m, c = 0 cont = ‘y’ While con= ’y’ Input cont? If u=C,F,K,R If u=C If u=F If u=K If u=R Input Temp Input Temp Input Temp Input Temp n=n+1 Cel=temp Fah=((5/9)*temp)+32 Kel=temp+273.15 Ran=((9/5)*temp)+491.69 N=n+1 Fah=temp Cel=(5/9)*(temp-32) Kel=((5/9)*(temp-32))+273.15 Ran=temp+459.69 N=n+1 Kel=temp Cel=temp-273.15 Fah=(9/5)*(temp-273.15)+491.69 Ran=temp+459.69 N=n+1 Ran=temp Cel=(5/9)*(temp-491.69) Far=temp-459.69 Kel=((5/9)*((temp-459.69)-32)+273.15) Conv to vector Celcius Fahrenheit Kelvin Rankine Conv to vector Celcius Fahrenheit

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}