Recent results revived the interest in the implementation of analog devices able to perform brainlike operations. Here we introduce a training algorithm for a memristor network which is inspired by previous work on biological learning. Robust results are obtained from computer simulations of a network of voltage-controlled memristive devices. Its implementation in hardware is straightforward, being scalable and requiring very little peripheral computation overhead.