How can I extract daily data of over 40 years to calculate monthly mean?

2 vues (au cours des 30 derniers jours)
Anthony Sciotto
Anthony Sciotto le 29 Nov 2019
I am having trouble using the daily temperature data (I have provided it) to extract the mean monthly temperature, the extreme minimum monthly temperature, and the extreme maximum monthly temperature. The nan values should not be accounted for.
For example, I would like to be able to obtain the values for the min, max and mean of all the january's. I will proceed with the rest

Réponses (1)

Kavya Vuriti
Kavya Vuriti le 3 Déc 2019
Hi,
The data in the csv file can be imported into MATLAB either as vectors or numeric matrix. Try importing as numeric matrix variable named ‘Data’. The matrix ‘Data’ contains 9 columns according to the attached csv file. To find min, max and mean of January temperatures, the sample code may look like this:
% Max temperature
maxTempJan = Data((Data(:, 2) == 1), 4);
maxTemp = max(maxTempJan);
% Min temperature
minTempJan = Data((Data(:, 2) == 1), 6);
minTemp = min(minTempJan);
% Mean temperature
meanTempJan = Data((Data(:, 2) == 1), 8);
% Consider values which are not NaN
meanTempJan = meanTempJan(~isnan(meanTempJan));
meanTemp = mean(meanTempJan);
This can be written in a loop to obtain values for all months.

Catégories

En savoir plus sur Variables 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!

Translated by