Retrieve the time that a certain value is reached within a time series.

15 ビュー (過去 30 日間)
jake Hawley
jake Hawley 2016 年 1 月 12 日
回答済み: Israel Vargas 2019 年 1 月 13 日
I am running a Simulink model and am changing constant to see how the system responds. I want to know what time the system reaches a certain value at each of the constants. I have same the time series to the work space but can not figure out how to extract the time at which the value becomes true.

採用された回答

goerk
goerk 2016 年 1 月 12 日
A simple way is to extract the data and the time as arrays
% create example data
d=1:100;
t=d/100;
ts = timeseries(d,t);
% define threshold
thr = 55;
data = ts.data(:);
time = ts.time(:);
ind = find(data>thr,1,'first');
time(ind) %time where data>threshold
  3 件のコメント
jake Hawley
jake Hawley 2016 年 1 月 12 日
Figured it out, the value i was looking for ended up being the max value so the vector never became greater than it so i needed to turn
ind = find(data>thr,1,'first');
to
ind = find(data=>thr,1,'first');
Ryan Wang
Ryan Wang 2018 年 8 月 20 日
Thank you so much goerk. This answer is truly helpful!

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

その他の回答 (1 件)

Israel Vargas
Israel Vargas 2019 年 1 月 13 日
Hi, excelent way to find a value in vectors. I'm doing something similar. While I'm running the simulation (in real time) I would like to get the especific time when a diferent signal change to a especific value. I have tried to edit what your writed but with bad results. I suppose because the dimentions of the time and the voltage signals are changing while the simulation is running. Please help me!

カテゴリ

Help Center および File ExchangeSources についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by