How to only consider data after a series of time points
2 次查看(过去 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!