Clear Filters
Clear Filters

Find maxima in proximity

2 views (last 30 days)
Raphael Willi
Raphael Willi on 25 Jun 2021
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.

Answers (1)

sai charan sampara
sai charan sampara on 4 Mar 2024
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

Categories

Find more on Data Types in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!