view general/numerical/nary.m @ 6:0ce3c2070089

Removed duplicate code and fixed doc in timed_action.
author samer
date Mon, 14 Jan 2013 14:33:37 +0000
parents e44f49929e56
children
line wrap: on
line source
% binary - return array contain binary sequece over N columns
%
% binary :: M:natural, N:natural -> [[M^N,N]->1..M].

function B=nary(M,N)

if (N==1), B=(1:M)';
else
	b=nary(M,N-1);
	m=size(b,1);
	B=[ kron((1:M)',ones(m,1)), repmat(b,M,1)];
end