The real rank of algebras of matrix valued functions