function s = dec2baseM(n,M,L)
% dec2baseM - convert a decimal number to base M
%
% Convert a decimal number into its base M equivalent and store the
% result in a vector of length L with the most significant bit in the first
% position. (n < M^L)
%
% s = dec2baseM( n, M, L)

s = zeros(1,L);

for i = L:-1:1
	s(i) = rem(n,M);
	n = (n-s(i))/M;
end
