Hello, I am trying to find the force values for less than 10N . Then I need to use the Max and Min indicies found from force < 10N. Using those indicies I need to find the two corresponding time values/indicies. Then I need to find the difference in time between the max and min.
The imported data is 2 colums of equal rows of data labeled Time(s), and Force(N).
close all; clear all; clc;GRF1 = importdata('GRF_1.txt'); %Imports data from selected text file.
time = GRF1.data(:,1); %takes the time values from colum 1 and stores them into a variable named time.
force = GRF1.data(:,2); %takes the force values from column 2 and stores them into a variable named force.
indBefore10 = find(force<10); %Finds all indicies which the force value is <10 .
[maxForce10, maxIndForce10] = max(indBefore10) %finds the MAX force, and its corresponding index.
[minValForce10, minIndForce10] = min(indBefore10); %finds the MIN force, and its corresponding index.
MinTimeInd = find(time == minIndForce10) %I think this takes the MIN force index found and finds corresponding time value from index.
MaxTimeInd = find(time == maxIndForce10) %I Think this takes the MAX force index found and finds corresponding time value from index.
TimeDiff = MaxTimeInd - MinTimeInd %Should calculate the difference between the max and min time values found.
So. The problem I am having is that the when I try to use the Force index in time I get a value which doesnt correspond to the correct index. Also my MaxTimeInd is returning and empty colum vector. Finally, I notice that "indBefore10 = find(force<10);" is returning a long list of values which exceed 10. Any help to figure this out would be greatly appreciated.
Best Answer