Derivation of the Matalon-Packter law for Liesegang patterns