function force = interp(t, samfunc, samt); % This file is a helper to beam_model_demo. Please see there for % documentation loc = find(samt == t); if length(loc) == 1 force = samfunc(loc); else low = max(find(samt < t)); high = min(find(samt > t)); if (length(low) < 1) force = samfunc(1); elseif (length(high) < 1) | (high > length(samfunc)) force = 0; else m = (samfunc(high) - samfunc(low)) ./ (samt(high) - samt(low)); force = m*t + samfunc(low) - m*samt(low); end end