How to calculate th mean/average value for a repetetive time step
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Jon
le 13 Mai 2022
You should be able to use MATLAB's movmean https://www.mathworks.com/help/matlab/ref/movmean.html for this without any loops
0 commentaires
Voir également
Catégories
En savoir plus sur Climate Science and Analysis dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!