function y = decay(t,m,more_args) % % Calculate f(t) = exp(-t/tc)*cos(omega*t) if m=0 % or its first, second, or third derivative if m=1,2,3 % % Inputs: % t = list of times % m = 0, 1, 2, or 3 % more_args = [tc omega] = time constant, frequency % error(nargchk(3,3,nargin)); tc = more_args(1); omega = more_args(2); e = exp(-t/tc); c = cos(omega*t); s = sin(omega*t); switch m case 0 %% get function value y = e.*c; case 1 %% get first deriv y = case 2 %% get second deriv y = case 3 %% get third deriv y = otherwise error('Fourth and higher derivatives unsupported!'); end