I am trying to extract the freez-thaw cycles in a timetable.freezing of stone only occur when the temperature drops below3 °C in a day and thawing when temperature rises above 1 °C in next day. My quastion is that how can I define a function for it and then retime the time table based on it.
I need to find the days with mean temperature below3 °C, followed by a day with mean temperature above 1 °C.(meteorological data file in attachment.)

 채택된 답변

Andrei Bobrov
Andrei Bobrov 2019년 10월 17일
편집: Andrei Bobrov 2019년 10월 18일
i = diff(3*(data_mean_daily.tabrizmat7 < -3) + (data_mean_daily.tabrizmat7 > 1)) == -2;
T_out = data_mean_daily([i;false]|[false;i],:);
as at Sebastian:
i = (data_mean_daily.tabrizmat7(1:end-1) < -3) & (data_mean_daily.tabrizmat7(2:end) > 1);
T_out = data_mean_daily(find(i(:)')+[0;1],:);

댓글 수: 8

Thanks but the second part of my question: this day must follow by a day with temp>4
why did you put ==-2 in first line?
1 - 3 = -2 :)
k = 3*(data_mean_daily.tabrizmat7 < -3) + (data_mean_daily.tabrizmat7 > 1);
% in k: 3 - days with temp < -3, 1 - days with temp > 1 degree
i = diff(k) == -2; % our days (1 - 3 = -2)
T_out = data_mean_daily([i;false]|[false;i],:);
dear Andrei thanks for your answers,
difference between -3 and +1 is 4. should I put 4 instead of 2?
Andrei Bobrov
Andrei Bobrov 2019년 10월 18일
편집: Andrei Bobrov 2019년 10월 18일
T_out in my comment gives the correct result?
I gave a solution for "I need to find the days with mean temperature below−3 °C, followed by a day with mean temperature above 1 °C."
Dear Andrei.
Yes,it give the correct answer but in result both of ddays are appeared.i.e: if 18th january temp increrase to above +1 and the day before is -3, in result(which the number of days are important) both of them are appeared. So we can see coupled days for each result. another question(since I wanna learn for my next tries): why did you multiply first value by 3(*3)?
one more q: how can I compare the day with the day before?
k = 3*(data_mean_daily.tabrizmat7 < -3) + (data_mean_daily.tabrizmat7 > 1);
k is the vector of days, if the element has a value of 3, then the temperature of this day is less than -3, if the value is 1, the temperature is more than +1. We are looking for a combination in our case [3; 1] or diff([3;1]).

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Sebastian Bomberg
Sebastian Bomberg 2019년 10월 17일
You can offset temperature by one day and compare against >= 4.
idx = data_mean_daily.tabrizmat7(1:end-1) >= 2 & ... % temp at current day greater 2 AND
data_mean_daily.tabrizmat7(2:end) >= 4; % temp at next day greate 4
data_mean_daily(idx,:)
idx has one row less than data_mean_daily but the missing last row will be treated as false anyway.

카테고리

도움말 센터File Exchange에서 Tables에 대해 자세히 알아보기

제품

릴리스

R2018b

태그

질문:

2019년 10월 17일

편집:

2019년 10월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by