function period = Zero_x(U,Time) % Zero_x -- calculate Zero Crossing Period % % U is an oscillatory variable, a vector of values % spaced in time. % Time is the time interval spanned by the values % of U. % period is the zero crossing period, in the same % units as Time. % % Fran Hotchkiss, January 8, 1998. whichzeroes = find(U==0.); U(whichzeroes) = 1; signofU = sign(U); signchanges = diff(signofU); changes = find(signchanges); howmany = length(changes); if howmany ~= 0 period = 2*Time/howmany; else period = 4*Time; end