function c = matnchoosek(n,k)

g = gammaln(n+1) - gammaln(k+1) - gammaln(n-k+1);

c = floor(exp(g)+.5);

% if any( [n k] <= 0 )
%     error('matnchoosek takes positive inputs')
% end
% m = n(:);
% k = k(:);
% M = length(m);
% for i = 1:M
%     c(i) = nchoosek(m(i),k(i)) ;
% end
% c = reshape(c,size(n));