how to find time interval of peak value in a timeseries ?

2 ビュー (過去 30 日間)
Harish Dhanasekaran Velayutha Rajan
コメント済み: Star Strider 2017 年 8 月 4 日
i have a load profile data set.. Time vs Load Demand as a timeseries object. If I have a threshold for peak as 800KW How do I find at what time my value goes above 800 kW ? The time series object is for every 30 mins interval over 24 hrs.
I need to find the highlighted time interval in the picture. Any idea?

採用された回答

Star Strider
Star Strider 2017 年 8 月 4 日
If you want to interpolate to find the ‘exact’ time, this works:
t = 0 : 30 : 1440;
LD = 500 + 400*sin(2*pi*t/2880);
zci = @(v) find(v(:).*circshift(v(:), [-1 0]) <= 0); % Returns Approximate Zero-Crossing Indices Of Argument Vector
X800_idx = zci(LD - 800); % Subtract 800, Find Approximate Zero-Crossing
LD800_Rng = LD(X800_idx-1 : X800_idx+1)'; % Define Range For Interpolation
t800_Rng = t(X800_idx-1 : X800_idx+1)'; % Define Range For Interpolation
t800 = interp1(LD800_Rng, t800_Rng, 800, 'linear', 'extrap'); % Find ‘Exact’ Time (Minutes)
figure(1)
plot(t, LD)
hold on
plot(t800, 800, '*r')
hold off
grid
  1 件のコメント
Star Strider
Star Strider 2017 年 8 月 4 日
A slightly more robust version that finds the points where ‘LD’ crosses 800:
t = 0 : 30 : 1440; % Create Data
LD = 500 + 400*sin(2*pi*t/2880); % Create Data
zci = @(v) find(v(:).*circshift(v(:), [-1 0]) <= 0); % Returns Approximate Zero-Crossing Indices Of Argument Vector
X800_idx = zci(LD - 800); % Subtract 800, Find Approximate Zero-Crossing
for k1 = 1:numel(X800_idx)
LD800_Rng = LD(X800_idx(k1)-1 : X800_idx(k1)+1)'; % Define Range For Interpolation
t800_Rng = t(X800_idx(k1)-1 : X800_idx(k1)+1)'; % Define Range For Interpolation
t800(k1) = interp1(LD800_Rng, t800_Rng, 800, 'linear', 'extrap'); % Find ‘Exact’ Time (Minutes)
end
figure(1)
plot(t, LD) % Plot Load Curve
hold on
plot(t800, [1 1]*800, '*r') % Plot ‘Load = 800’ Points
hold off
grid

サインインしてコメントする。

その他の回答 (1 件)

fbaillon
fbaillon 2017 年 8 月 4 日
You can use the find function:
T= ... % Time
LD= .... % Load Demand
timeYouWant=T(find(LD>800e3,1,'first))
Something like that...

カテゴリ

Help Center および File ExchangeMultirate Signal Processing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by