Indexnummer eines DateTime Array mit Prozent finden

1 回表示 (過去 30 日間)
Christian Bothe
Christian Bothe 2025 年 1 月 25 日
コメント済み: Christian Bothe 2025 年 1 月 25 日
Ich suche den Index eines Zeitpunktes aus einem DateTime Array 90% vom gesamten set.
Das ist das original mit einem Zeitpunkt als Suche.
backtest_start_idx = find(date_vector < datetime(2022,2,1),1,'last')
Hier der Versuch mit 90% als Suche.
Es werden aber realnumbers erwartet.
backtest_start_idx = prctile(date_vector,90)
  1 件のコメント
Christian Bothe
Christian Bothe 2025 年 1 月 25 日
Der AI-Playground ist deutlich effektiver und lieferte das.
Ich benutze den zum 1. mal
% Example dataset of datetime values
data_datetime = [
datetime('2023-01-01 12:00:00');
datetime('2023-01-02 12:00:00');
datetime('2023-01-03 12:00:00');
datetime('2023-01-04 12:00:00');
datetime('2023-01-05 12:00:00');
datetime('2023-01-06 12:00:00');
datetime('2023-01-07 12:00:00')
];
% Convert datetime to numeric for percentile calculation
data_numeric = posixtime(data_datetime);
% Calculate the 90th percentile
p90 = prctile(data_numeric, 90);
% Convert back to datetime
datetime_90th_percentile = datetime(p90, 'ConvertFrom', 'posixtime');
disp(['90th Percentile datetime: ', datestr(datetime_90th_percentile)]);

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

回答 (0 件)

製品


リリース

R2024b

Community Treasure Hunt

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

Start Hunting!