How to calculate th mean/average value for a repetetive time step
    5 次查看(过去 30 天)
  
       显示 更早的评论
    
I have a daily temperature Data frome 1951 to 2005. 
 i want to create a loop to calculate the mean value of the temperature each Dt =20 days from 1 Jan 1951 to 31 Dec 2005 and plot it. ( the mean value will be plotted in the middl of Dt).
The main objective is to get a plot like the photo attached.
clear all
    close all
    clc
    % NAME OF THE PROJECT %%
    %%%%% PLACE %%%%
    %  TEMPERATURE MODEL 3.5 HISTORICAL
    Temperature = xlsread("File name", "B3:B12786" ); %import temperature data
    writematrix(Temperature, 'Temp.txt');
    Temp= readmatrix("Temp.txt");
    % create the timetable [DD MM YYYY]
    year0=1971; 
    temps=timetable(Temp,'RowTimes',datetime(year0,1,1:height(Temp)));
for i = 1 : length (Temp)
% .... ???
end
My data is then represented like this : 
  Variable                          Near-Surface Air Temperature
  Datetime                          Number
  Unit                                  Degree Celsius
  01-janv-1951                  1.0442
  02-janv-1951                    2.0769
  03-janv-1951                    9.1496
  04-janv-1951                     6.8813
.
12-mai-1999                	11.3024
13-mai-1999	                12.6448
14-mai-1999	                 13.0754
.
.

Figure source: Climate Impacts Group, based on climate projections used in the IPCC 2013 report.
0 个评论
回答(1 个)
  Jon
      
 2022-5-13
        You should be able to use MATLAB's movmean https://www.mathworks.com/help/matlab/ref/movmean.html for this without any loops
0 个评论
另请参阅
类别
				在 Help Center 和 File Exchange 中查找有关 Climate Science and Analysis 的更多信息
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

