diff --git a/dune/istl/io.hh b/dune/istl/io.hh
index 6d611b926f994bb3eec9706852e08d20849d1237..85b6644a949826794aa8b090822e93a7a3a320b7 100644
--- a/dune/istl/io.hh
+++ b/dune/istl/io.hh
@@ -17,6 +17,8 @@
 #include <dune/common/fmatrix.hh>
 
 #include <dune/istl/matrix.hh>
+#include <dune/istl/diagonalmatrix.hh>
+#include <dune/istl/scaledidmatrix.hh>
 #include "bcrsmatrix.hh"
 
 
@@ -391,6 +393,44 @@ namespace Dune {
     };
   } // anonymous namespace
 
+  //! Helper method for the writeMatrixToMatlab routine.
+  /**
+   * \code
+   *#include <dune/istl/io.hh>
+   * \endcode
+   *
+   * This specialization for DiagonalMatrices ends the recursion
+   */
+  template <class FieldType, int dim>
+  void writeMatrixToMatlabHelper(const ScaledIdentityMatrix<FieldType,dim>& matrix, int rowOffset, int colOffset, std::ostream& s)
+  {
+    for (int i=0; i<dim; i++)
+    {
+      //+1 for Matlab numbering
+      s << rowOffset + i + 1 << " " << colOffset + i + 1 << " ";
+      MatlabPODWriter<FieldType>::write(matrix.scalar(), s)<< std::endl;
+    }
+  }
+
+  //! Helper method for the writeMatrixToMatlab routine.
+  /**
+   * \code
+   *#include <dune/istl/io.hh>
+   * \endcode
+   *
+   * This specialization for DiagonalMatrices ends the recursion
+   */
+  template <class FieldType, int dim>
+  void writeMatrixToMatlabHelper(const DiagonalMatrix<FieldType,dim>& matrix, int rowOffset, int colOffset, std::ostream& s)
+  {
+    for (int i=0; i<dim; i++)
+    {
+      //+1 for Matlab numbering
+      s << rowOffset + i + 1 << " " << colOffset + i + 1 << " ";
+      MatlabPODWriter<FieldType>::write(matrix.diagonal(i), s)<< std::endl;
+    }
+  }
+
   //! Helper method for the writeMatrixToMatlab routine.
   /**
    * \code