Extract extremes of sample1 occurring within a time window of sample2
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Hello everyone,
I am a Matlab Newbie and would therefore highly appreciate your help to my question.
I have two samples of extreme values, extracted from a POT analysis and their corresponding timing of occurrence (hourly values), with different lengths, for example:
Ex1 = [10 9 9 7 10 11 12];
Ex2 = [100 345 234 66 878 595 444 434 90];
Ext1 = [1:7,1]; %length of time vector 1
Ext2 = [1:9,1]; %length of time vector 2
I would now like to extract the extreme values of Ex1, which occur within a time window of +- 72 hours of the extreme values of Ex2.
Could anyone help me with this?
Many Thanks,
Sunna
0 Commenti
Risposte (1)
Arun
il 16 Feb 2024
Hi Sunna,
I understand that you wish to extract extreme values in Ex1, based on the extreme values in Ex2. The extreme values in Ex1 should be within 72 hours of extreme values in Ex2. The extreme values are not distinct and can have multiple occurrences.
Here is a code that finds the extremes in Ex2, then find the values in Ext1 that are in 72 hours window to the extreme values in Ex2, and then finally finds the extremes in Ex1.
Ex1 = [10 9 7 7 10 11 12]
Ex2 = [100 345 234 66 878 595 444 434 90]
Ext1 = [1:7] %length of time vector 1
Ext2 = [1:9] %length of time vector 2
% Find the indexes for extreme values in Ex2
% Extreme values include both max and min values.
% find the min indexes
minIndex = find(Ex2 == min(Ex2));
%find the max indexes
maxIndex = find(Ex2 == max(Ex2));
%combine the indexes for extreme values
relevantIndex = union(maxIndex,minIndex);
%assume dummy values for max and min in Ex1
minEx1 = intmax;
maxEx1 = intmin;
[~,sizeofExt1] = size(Ext1);
%create an array to store relavant indexes in Ex1
indexArr= [];
% get the relevant index to check in Ex1
for j = 1:sizeofExt1
for k = relevantIndex
% check time with in the window
if(Ext1(j)>Ext2(k)-71 || Ext1(j)<Ext2(k)+71)
indexArr = [indexArr,j]; % add relavant indexes
break;
end
end
end
%check relevant index in Ex1
for j=indexArr
%find min
if(minEx1 >= Ex1(j))
minEx1 = Ex1(j);
end
%find max
if(maxEx1 <= Ex1(j))
maxEx1 = Ex1(j);
end
end
% display the output
x = sprintf('Extream in Ex1 are:%d and %d ',minEx1,maxEx1);
disp(x);
Hope this helps.
0 Commenti
Vedere anche
Categorie
Scopri di più su Logical in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!