diff --git a/matlab/dyn_saveas.m b/matlab/dyn_saveas.m
index 7c14dd523c1a860ff373d6fcc162725c8531de91..12c580af9fc95a68d3018e42b53c98ce20132d55 100644
--- a/matlab/dyn_saveas.m
+++ b/matlab/dyn_saveas.m
@@ -31,6 +31,13 @@ function dyn_saveas(h,fname,DynareOptions)
 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
 
 if any(strcmp('eps',cellstr(DynareOptions.graph_format)))
+    if exist('OCTAVE_VERSION')
+        fname = strrep(fname,'/',filesep);
+        fname = strrep(fname,'\',filesep);
+        if DynareOptions.nodisplay && ispc,
+            set(h, 'Visible','on');
+        end
+    end
     print(h,'-depsc2',[fname,'.eps']) 
 end
 if any(strcmp('pdf',cellstr(DynareOptions.graph_format)))