Suppose that A is a nonnegative n × m real matrix. The NMF problem is the determination of two nonnegative real matrices F , V so that A = F V with intermediate dimension p smaller than min{n, m}. In this article we present a general mathematical method for the determination of two nonnegative real factors F, V of A. During the first steps of this process the intermediate dimension p of F, V is determined, therefore we have an easy criterion for p. This study is based on the theory of lattice-subspaces and positive bases. Also we give the matlab program for the computation of F, V but the mathematical part is the main part of this article.