duration of rain. help

1Â vue (au cours des 30Â derniers jours)
Nikita le 7 Mar 2024
CommentÃ©Â : Mathieu NOE le 27 Mar 2024
Good afternoon, I have a file. It is not possible to find the average monthly duration of rain and its intensity.
Maybe someone can help. Thank you in advance
2Â commentairesAfficher AucuneMasquer Aucune
Dyuman Joshi le 7 Mar 2024
ModifiÃ©(e)Â : Dyuman Joshi le 7 Mar 2024
It's not clear (atleast to me) what you have asked/want to do.
Please clearly specify what the objective is, mention the code that you have written yet and state the issue you are facing.
Nikita le 7 Mar 2024
I cannt't undenstand how calculation duration of rain in matlab code

Connectez-vous pour commenter.

Mathieu NOE le 7 Mar 2024
hello
this is one way to do it - just plain simple matlab functions .
Of course , someone fluent with timetables can do it also , probably in few lines
this is my "old fashioned" way....
I don't see how rain intensity appears in your data - can you explain what are columns 9 to 16 ?
for the time being I simply computed the total amount of minutes of rain for each month and each year
% store data (year / month / total rain duration (minutes)
code done so far
% cols : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
% id Year Mn Da Rain hr.min_start hr.min_finish
years = T(:,2);
month = T(:,3);
hr_min_start = T(:,17);
hr_min_finish = T(:,18);
[year_u,ia,ic] = unique(years);
out = [];
% loop over the years
for k = 1:numel(year_u)
% extract rows
rows_y = find(abs(years - year_u(k))<1); % more robust than == 0
% loop over the months
for mk = 1:12
month_list = month(rows_y);
% extract rows
rows_m = find(abs(month_list - mk)<1); % more robust than == 0
if ~isempty(rows_m) % we have data
hr_min_start_m = hr_min_start(rows_m); % extract start time
start_minutes = myconvert(hr_min_start_m); % convert to minutes
hr_min_finish_m = hr_min_finish(rows_m); % extract finish time
finish_minutes = myconvert(hr_min_finish_m); % convert to minutes
duration_minutes = finish_minutes - start_minutes;
% some duration appears negative simply because 0:00 is same
% as 24:00 , so we have to complement with 24*60 = 1440
% minutes
ind = (duration_minutes<0);
duration_minutes(ind) = duration_minutes(ind) + 1440;
total_duration_minutes = sum(duration_minutes);
flag_store = 1;
else
total_duration_minutes = 0;
flag_store = 0;
end
% store data (year / month / duration(minustes)
if flag_store~= 0
out = [out; [year_u(k) mk total_duration_minutes]];
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function out_minutes = myconvert(time)
% time format is like 22.40 (hours = 22 , minutes = 40)
% convert this in minutes only
hh = floor(time); % hours
mm = time - hh; % minutes
out_minutes = mm+60*hh;
end
8Â commentairesAfficher 6 commentaires plus anciensMasquer 6 commentaires plus anciens
Nikita le 27 Mar 2024
Yes, of course. Many thanks
Mathieu NOE le 27 Mar 2024
Thank you !

Connectez-vous pour commenter.

Image Analyst le 27 Mar 2024
You might look into splitapply, grpstats, groupsummary, and findgroups. They are very useful functions to know about! ðŸ™‚
1Â commentaireAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens
Image Analyst le 27 Mar 2024
If an Answer solves your original question, then could you please click the "Accept this answer" link/button to award the answerer with "reputation points" for their efforts in helping you? They'd appreciate it. Thanks in advance. ðŸ™‚ Note: you can only accept one answer (so pick the best one - Matthew's) but you can click the "Vote" icon for as many Answers as you want. Voting for an answer will also award reputation points.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by