How to calculate th mean/average value for a repetetive time step
조회 수: 4 (최근 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!