Mercurial > repos > public > sbplib
diff alignedTimestep.m @ 12:c71095442c57
Added function to calculate an aligned timestep.
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Tue, 22 Sep 2015 08:35:57 +0200 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/alignedTimestep.m Tue Sep 22 08:35:57 2015 +0200 @@ -0,0 +1,12 @@ +% Calcualtes the largest timestep smaller than k_max that gives an integer +% number of timesteps to time T. +% k_max -- largest allowable timestep +% T -- time to align with +% +% Returns: +% k -- calculated timestep +% N -- number to of timestep to reach T +function [k, N] = alignedTimestep(k_max, T) + N = ceil(T/k_max); + k = T/N; +end \ No newline at end of file