How to rid HIC calculation of nested for loops
Show older comments
HIC (Head Injury Criteria) is a biomechanics calculation performed on an acceleration time history (https://en.wikipedia.org/wiki/Head_injury_criterion).

Since my FORTRAN days, I've always used nested for loops such as:
function [HICvalue, iT1, iT2, avgAcc] = HIC(RAcc, DeltaT, Win)
% RAcc is a resultant in "g"s (always +)
% DeltaT is uniform number of seconds between every point in RAcc
% Win is a time (in mS) window limit which the calculation is not to exceed
winpts = round((Win/1000)./DeltaT);
pts = length(RAcc);
area = cumtrapz(RAcc(:,1)).*DeltaT;
HICvalue = -1;
for i=1:winpts
for j = 1:pts-i
Temp = (( (1.0/(i.*DeltaT)) * (area(j+i) - area(j)) )^2.5)* i * DeltaT;
if(Temp > HICvalue)
HICvalue = Temp;
iT1 = j;
iT2 = j+i;
avgAcc = (1.0/(i.*DeltaT)) * (area(j+i) - area(j));
end
end
end
end
Now that sample frequencies are in the millions, making the acceleration arrays huge, this method has lost its shine [and takes too long]!
Might anyone please help an old dog simplify this [using matrices...], getting rid of the point-wise nested looping?
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!