mean and some in each row, col is not correct.

1 visualización (últimos 30 días)
Gurumoorthi K
Gurumoorthi K el 13 de Jul. de 2023
Respondida: Cris LaPierre el 13 de Jul. de 2023
Dear all,
I am using following code for calculating monthly mean and sum (step 1) and seasonal mean (intensity) and sum (days) (step 2).
step 1.
[mhw_ts_monthly_days tmean_month] = downsample_ts(double(~isnan(mhw_ts)),datenum(date_used),'monthly','sum');
[mhw_ts_monthly_meanInt tmean_month] = downsample_ts(mhw_ts,datenum(date_used),'monthly','nanmean');
step 2.
spring = [9 10 11]; % Sep, Oct, Nov
summer = [12 1 2]; % Dec, Jan, Feb
autumn = [3 4 5]; % Mar, Apr, May
winter = [6 7 8]; % Jun, Jul, Aug
% Seasonal output for each year.
id_summer=ismember(month(datetime(tmean_month,'ConvertFrom','datenum')),summer);% for Dec, Jan, Feb
[meanInt_summer_annual_mean tmean_summer_ann]=downsample_ts(mhw_ts_monthly_meanInt(:,:,id_summer),tmean_month(id_summer),'yearly','nanmean');% for summer annual mean
[days_summer_annual_sum tmean_summer_d_ann] = downsample_ts(double(~isnan(mhw_ts_monthly_days(:,:,id_summer))), tmean_month(id_summer), 'yearly', 'sum');%for summer annual sum
days_summer_annual_sum(days_summer_annual_sum==0) = NaN;
calculated seasonal mean snd sum is not correct when i compare to the annual mean by using below code.
[mhw_ts_monthly_days tmean_month] = downsample_ts(double(~isnan(mhw_ts)),datenum(date_used),'monthly','sum'); % for monthly sum of days for each grid
mhw_ts_monthly_days(mhw_ts_monthly_days==0) = NaN;
[mhw_ts_annual_days tmean_year] = downsample_ts(double(~isnan(mhw_ts)),datenum(date_used),'yearly','sum'); % for anuual sum of days for each grid
mhw_ts_annual_days(mhw_ts_annual_days==0) = NaN;
Kidly advise me where I am doing wrong. It would be great if anybody modify or correct the code.
Thanks
  4 comentarios
Stephen23
Stephen23 el 13 de Jul. de 2023
Please attach the function downsample_ts and all the corresponding data. Use the paperclip button to do so.
Gurumoorthi K
Gurumoorthi K el 13 de Jul. de 2023
downsample_ts function:
input file is not uploaded due to file size restriction. screen shot is attached for your understanding.
S=input file dimension
data=input file after loading

Iniciar sesión para comentar.

Respuestas (1)

Cris LaPierre
Cris LaPierre el 13 de Jul. de 2023
If you attach your data set, perhaps we can be more helpful. In the meantime, you might find the "Performing Group Calculations" video from our Exploratory Data Analysis course on Coursera helpful.
I would first convert any datenums to datetimes. I would then use groupsummary to compute monthly and seasonal mean/sum. You can also do this interactively using the Compute by Group task in a live script.

Categorías

Más información sobre Data Type Conversion en Help Center y File Exchange.

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by