How to only consider data after a series of time points
3 ビュー (過去 30 日間)
古いコメントを表示
I have a Force x Time graph, and I am trying to write a code to determine the time point when the Force drops below 0, on the condition that it has already decreased past threshold 1 value, then increased past threshold 2 value, then decreased past threshold 3 value. How can I ensure these criteria have been met before i look for my first 0 value using
F1 = find(F < 0.001, 1, 'first')
Thanks in advance
0 件のコメント
回答 (1 件)
Ridwan Alam
2019 年 12 月 3 日
編集済み: Ridwan Alam
2019 年 12 月 3 日
If I understood it right, you have threshold values T0(=0?),T1,T2,T3:
F0 = find(F(2:end)<T0 & F(1:end-1)>=T0) +1; % indices of F decreasing past T0
F1 = find(F(2:end)<T1 & F(1:end-1)>=T1) +1; % indices of F decreasing past T1
F2 = find(F(2:end)>=T2 & F(1:end-1)<T2) +1; % indices of F increasing above T2
F3 = find(F(2:end)<T3 & F(1:end-1)>=T3) +1; % indices of F decreasing past T3
if ~isempty(F1)
tempF2 = F2(F2>F1(1));
if ~isempty(tempF2)
tempF3 = F3(F3>tempF2(1));
if ~isempty(tempF3)
finalIndex = F0(find(F0>tempF3(1),1,'first'));
end
end
end
Hope it helps!
1 件のコメント
Ridwan Alam
2019 年 12 月 3 日
編集済み: Ridwan Alam
2019 年 12 月 3 日
BW = mean(F(4000:5000))
T1 = BW*0.9
T2 = BW*1.2
T3 = BW*0.9
T0 = 0
% BW =
% 774.3022
% T1 =
% 696.8720
% T2 =
% 929.1626
% T3 =
% 696.8720
F0 = find(F(2:end)<T0 & F(1:end-1)>=T0) +1; % indices of F decreasing past T0
F1 = find(F(2:end)<T1 & F(1:end-1)>=T1) +1; % indices of F decreasing past T1
F2 = find(F(2:end)>=T2 & F(1:end-1)<T2) +1; % indices of F increasing above T2
F3 = find(F(2:end)<T3 & F(1:end-1)>=T3) +1; % indices of F decreasing past T3
if ~isempty(F1)
tempF2 = F2(F2>F1(1));
if ~isempty(tempF2)
tempF3 = F3(F3>tempF2(1));
if ~isempty(tempF3)
finalIndex = F0(find(F0>tempF3(1),1,'first'));
end
end
end
% finalIndex =
% 7372
参考
カテゴリ
Help Center および File Exchange で Clocks and Timers についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!