duration of rain. help

์กฐํšŒ ์ˆ˜: 6 (์ตœ๊ทผ 30์ผ)
Nikita
Nikita 2024๋…„ 3์›” 7์ผ
๋Œ“๊ธ€: Mathieu NOE 2024๋…„ 3์›” 27์ผ
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
Dyuman Joshi
Dyuman Joshi 2024๋…„ 3์›” 7์ผ
ํŽธ์ง‘: Dyuman Joshi 2024๋…„ 3์›” 7์ผ
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
Nikita 2024๋…„ 3์›” 7์ผ
I cannt't undenstand how calculation duration of rain in matlab code

๋Œ“๊ธ€์„ ๋‹ฌ๋ ค๋ฉด ๋กœ๊ทธ์ธํ•˜์‹ญ์‹œ์˜ค.

์ฑ„ํƒ๋œ ๋‹ต๋ณ€

Mathieu NOE
Mathieu NOE 2024๋…„ 3์›” 7์ผ
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
T = readmatrix('rain.xlsx',"NumHeaderLines",2);
% 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
Nikita
Nikita 2024๋…„ 3์›” 27์ผ
Yes, of course. Many thanks
Mathieu NOE
Mathieu NOE 2024๋…„ 3์›” 27์ผ
Thank you !

๋Œ“๊ธ€์„ ๋‹ฌ๋ ค๋ฉด ๋กœ๊ทธ์ธํ•˜์‹ญ์‹œ์˜ค.

์ถ”๊ฐ€ ๋‹ต๋ณ€ (1๊ฐœ)

Image Analyst
Image Analyst 2024๋…„ 3์›” 27์ผ
You might look into splitapply, grpstats, groupsummary, and findgroups. They are very useful functions to know about! ๐Ÿ™‚
  ๋Œ“๊ธ€ ์ˆ˜: 1
Image Analyst
Image Analyst 2024๋…„ 3์›” 27์ผ
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.

๋Œ“๊ธ€์„ ๋‹ฌ๋ ค๋ฉด ๋กœ๊ทธ์ธํ•˜์‹ญ์‹œ์˜ค.

ํƒœ๊ทธ

Community Treasure Hunt

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

Start Hunting!

Translated by