Clear Filters
Clear Filters

Monthly RMSE of daily data taken during a whole year

1 view (last 30 days)
I have my data on a table in which the first column has all the daily dates of a year (1-Jan-2014, 2-Jan-2014 ... ) and the second and third column contains values of mean daily temperatures calculated by two methods. I would like to compare this two methods calculating the monthly RMSE of the temperatures given by this two methods. That means that for each month, I would like to calculate the squared difference between the temperatures of each day, then the mean of that difference and finally the square root. Is there any way to select only the daily values of each different month taking into account that they have different number of days ? At the end I would like to obtain the 12 values of RMSE for each month, obtained comparing the daily temperatures of the third column (the true daily mean) and the second column (an approximation of the mean calculated by another method).
Thanks for your time.

Answers (1)

Ravi
Ravi on 14 Oct 2023
Hi Victor Martinez,
I understand that you are trying to find the RMSE of temperature over every month instead of computing it over the year.
Kindly follow the below steps,
  • Find the month to which a given date belongs to. For this, you can use the “month” function. But the function accepts a datetime object as an argument. Therefore, convert the table date entry into its corresponding datetime object.
month_function = @(dateStr) month(datetime(dateStr, "InputFormat", "dd-MM-yyyy"));
  • Use a for loop to iterate over the month numbers starting from 1 to 12. For each month number, extract the data that corresponds to that month number.
% target month is the current month in iteration
condition = month_function(data.date) == targetMonth;
monthData = data(condition, :);
  • From the extracted data,
  • Compute the difference of second and third columns. The result will be a vector.
  • Square every entry of the vector and sum them up.
  • Apply square root to the result, which is the required RMSE.
  • Concatenate the result to a list containing RMSE values for every month.
For more understanding on the above-mentioned functions, please refer to the following resources.
Hope this helps !

Categories

Find more on Dates and Time in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!