Double condition to find index

조회 수: 1 (최근 30일)
Jeanne Dury
Jeanne Dury 2022년 6월 24일
댓글: Jeanne Dury 2022년 6월 24일
I have force data from force plate and I try to determine the impact time/index.
For that, I need two conditions:
1) Data exceeds 20 newtons (>20)
2) Data exceeds 20 newtons for more than 50 milliseconds
I tried with for + if and with for using find fonction.
Do you have some idea to resolve that ?
Thank you so much.
  댓글 수: 3
James Tursa
James Tursa 2022년 6월 24일
What is the sampling rate of your recorded data?
Jeanne Dury
Jeanne Dury 2022년 6월 24일
The sample rate is 2000Hz

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2022년 6월 24일
freq = 2000; %hz
threshold = 20; %newtons
significant_time = 50; %milliseconds
significant_samples = ceil(significant_time/1000 * freq);
mask = ForceData(:).' > threshold;
streak = repmat(1, 1, significant_samples);
starts = strfind([false mask], [0 streak]);
stops = strfind([mask false], [streak 0]);
At this point, starts and stops will be vectors the same length, in which ForceData(starts(K):stops(K)) is a run of samples that exceed the threshold for at least as long as you require.
  댓글 수: 1
Jeanne Dury
Jeanne Dury 2022년 6월 24일
Thank you very much for your answer. It works perfectly!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Jonas
Jonas 2022년 6월 24일
myData=...;
fs=2000;
minLength=ceil(fs*0.05);
highVals=myData>20;
searchFor=conv(highVals,ones(1,minLength),'same');
% areas in which the condition is fullfilled are greater than your minLength
plot(searchFor);
findpeaks(searchFor>=minLength)

카테고리

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