Determine in what interval a variable is

4 ビュー (過去 30 日間)
Quist
Quist 2024 年 1 月 7 日
コメント済み: Quist 2024 年 1 月 7 日
I have a vector with timestamps for different phases, for example
ElapsedTime = [0.13 0.35 0.74 1.02 1.39 1.80 2.50];
Where the first phase is between time 0 and 0.13, the second phase is between 0.13 and 0.35 and so on.
The length and values of the vector are dynamic and changes from time to time.
How can I determine to which phase a specific time value belongs to?
t = 0:0.01:ElapsedTime(end);

採用された回答

Matt J
Matt J 2024 年 1 月 7 日
編集済み: Matt J 2024 年 1 月 7 日
ElapsedTime = [0.13 0.35 0.74 1.02 1.39 1.80 2.50];
t = 0:0.01:ElapsedTime(end);
phases = discretize(t, [0,ElapsedTime])
phases = 1×251
1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
  1 件のコメント
Quist
Quist 2024 年 1 月 7 日
Beautiful!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with Phased Array System Toolbox についてさらに検索

製品


リリース

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by