Output Max and Min values

1 view (last 30 days)
John
John on 13 Mar 2014
Commented: dpb on 13 Mar 2014
So I am wrote a code that has a user input a certain temperature, either in Celsius or Fahrenheit, then outputs the temperature in C, K, R, and F and then says if it is hot, cold, boiling based on the Celsius temperature. So, now I need to put the code in a while loop and it has to now output the previous stuff, as well as the Average temperature for each trial, and the Max and Min of the trial temperatures (in C). I am really lost on how to solve this and would love any help you can give
  3 Comments
John
John on 13 Mar 2014
Not exactly, I am outputting a temperature in Celsius and need to have my code decide if that value is the max and or min temperature, then run my program again in the while loop and then decide again if the first temperature was the max or min and if the second output temperature is a max or min
dpb
dpb on 13 Mar 2014
Then you must save the max and min values you find (the first time they'll be the same as the trial, obviously) as a new variable. On subsequent trials you would then compare the new value to the save previous max/min variables and only replace if the new exceeds the stored value.
For looping, see
doc while
My recollection is there's an example there that is repeated user input??? Or, is that on the input help? Anyway, there's examples enough of the various pieces to get a good start.
Since this sounds awfully lot like homework and we don't do homework straight out, post your efforts and ask more specific questions where you get stuck.

Sign in to comment.

Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!