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

2 Ansichten (letzte 30 Tage)
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

Antworten (1)

Kavya Vuriti
Kavya Vuriti am 3 Dez. 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.

Kategorien

Mehr zu Variables finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by