Find maxima in proximity

2 次查看(过去 30 天)
Raphael Willi
Raphael Willi 2021-6-25
I have 2 timetables with data covering the same time period at 2 different intervals.
I want to find the local maxima in the Q timetable ('st_Q_exert') that is within a 24 hour window of the daily T ('st_T_exert') maximum.
I grouped them together using:
TT = synchronize(st_T_exert,st_Q_exert,'union', 'linear');
First, I need the daily T max. I did this using:
dailyTemp= reshape(TT.Temp(1:end-1),288,[]);
>> [valT,indT]=max(dailyTemp);
indT gives me the index of each day where the maxima occured. I would now like to find the maximas of the other data table in a 24 hour window around these indexes.
for i=2:length(indT)
idxT_all(i)=indT(i)+288*(i-1);
end
This expands the indexing for the entire data set.
I would now like to do "search" the st_Q_exert in a window of size 288 around the indexes saved in idxT_all for the nearest maxima of Q around maxima of T.

回答(1 个)

sai charan sampara
Hello Raphael,
I understand you are trying to find the maximums in “st_Q_exert” around known indices of maximums in “st_T_exert” with a window of length 288. It can be done as follows:
load("Q_excerpt.mat");
load("T_excerpt.mat");
TT = synchronize(st_T_exert,st_Q_exert,'union', 'linear');
dailyTemp= reshape(TT.Temp(1:end-1),288,[]);
[valT,indT]=max(dailyTemp);
for i=2:length(indT)
idxT_all(i)=indT(i)+288*(i-1);
end
max_q=[];
for i=1:length(idxT_all)
lower_limit=idxT_all(i)-143;
upper_limit=idxT_all(i)+144;
if lower_limit<1
lower_limit=1;
end
if upper_limit>size(st_Q_exert,1)
upper_limit=size(st_Q_exert,1);
end
max_q(i)=max(st_Q_exert{lower_limit:1:upper_limit,"Q"});
end
max_q
max_q = 1×14
14.3020 20.5780 20.3880 16.3650 15.2140 14.4540 14.4160 14.6070 13.8930 13.0060 36.8630 63.4560 28.2650 18.4160

类别

Help CenterFile Exchange 中查找有关 Data Types 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by