diff --git a/preprocessor/ExprNode.cc b/preprocessor/ExprNode.cc
index 2aa85568eb218393741f2ae4b0226418691c24eb..1d0f4240a51b9295248ab5cf269f58a44568b834 100644
--- a/preprocessor/ExprNode.cc
+++ b/preprocessor/ExprNode.cc
@@ -4218,7 +4218,10 @@ TrinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
   temporary_terms_t::const_iterator it = temporary_terms.find(const_cast<TrinaryOpNode *>(this));
   if (it != temporary_terms.end())
     {
-      output << "T" << idx;
+      if (output_type == oMatlabDynamicModelSparse)
+        output << "T" << idx << "(it_)";
+      else
+        output << "T" << idx;
       return;
     }