function [start, stop] = FindEventPeriod(data) % FindEventPeriod find when system settles % This function was designed to determine the event time period of an % underdamped second order system. I decided that convergence of the % moving average was better than 5 tao due to issues determining the % period of the dataset. Moving_avg(index)set to >0.004, window size 50 [~, start] = FindMax(data); n = length(data); window_size = 50; moving_avg = movmean(abs(data(start:n)),window_size); index = 1; while moving_avg(index) > 0.002 if index == length(moving_avg) stop = index; break; end index = index + 1; stop = start + index; end end