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

조회 수: 1 (최근 30일)
Anthony Sciotto
Anthony Sciotto 2019년 11월 29일
답변: Kavya Vuriti 2019년 12월 3일
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

답변 (1개)

Kavya Vuriti
Kavya Vuriti 2019년 12월 3일
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.

카테고리

Help CenterFile Exchange에서 NetCDF에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by