How to only consider data after a series of time points

조회 수: 3 (최근 30일)
Charley Haynes
Charley Haynes 2019년 12월 3일
편집: Ridwan Alam 2019년 12월 3일
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

답변 (1개)

Ridwan Alam
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
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 CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by