Check if time equals time frame

1 回表示 (過去 30 日間)
Bas
Bas 2016 年 11 月 15 日
回答済み: Jan 2016 年 11 月 15 日
Hello,
I'm facing the following problem.
I have a matrix A(1000x1) containing time values in terms of time steps. I want to generate a matrix which identifies the events that fit within a certain time frame with respect to the time value in that row.
Example:
A(1,1)= 50
A(2,1)= 51
A(3,1)= 52
A(4,1)= 60
A(5,1)= 61
Now I want to generate a matrix B which shows the events that occur within the time frame A(1,1):(A(1,1)+4) in the first row of matrix B. And do that for every row in A. So B should be:
B(1,:)= [2 3]
B(2,:)= [3]
B(3,:)= []
B(4,:)= [5]
B(5,:)= []
Can anyone help me with this?

採用された回答

Jan
Jan 2016 年 11 月 15 日
B = cell(1, numel(A));
for k = 1:numel(A)
B{k} = find(and(A > A(k), A <= A(k) + 4));
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDesign of Experiments (DOE) についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by