Question: Code has already been provided to define a function named tempCounter that defines a single input variable named tempData that receives a vector of temperature

Code has already been provided to define a function named tempCounter that defines a single input variable named tempData that receives a vector of temperature values in units of degrees Celsius. Add code to the function to determine the two most frequent values in the data set using the built-in mode function. Assign the most frequent value to the output variable named temp1 and the number of instances for this value to the output variable named temp1count. Assign the second most frequent value to the output variable named temp2 and the number of instances for this value to the output variable named temp2count.
For example, given the input
tempData =[15201920141722202119222019];
The values assigned to the output variables should be temp1=20, temp1count =4, temp2=19, and temp2count =3.
Solve this problem using vectorized code (i.e. do not use a loop in your solution) that employs the built-in mode function. Note the variable tempData is assigned values as a function input. Do not overwrite these values in your code.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!