Is there friend know Emacs Org mode and Matlab here? I try to save Matlab plot into image file in another path instead of current working directory. Like bellowing code: #+headers: :var cwd=(expand-file-name "data/images/" (file-name-directory (buffer-file-name))) #+headers: :prologue "eval(sprintf("cd '%s'", cwd))" #+headers: :epilogue "saveas(gcf,'matlab-plot-demo2.png'); close(gcf);" #+begin_src matlab :results graphics file link :dir "data/images" :file "matlab-plot-demo2.png" :session "*MATLAB*" bar([1 11 7 8 2 2 9 3 6]) #+end_src #+RESULTS[(2023-04-13 00:09:01) c5fc0d36b27e75610664ee69ae618649637e45d9]: [[file:data/images/matlab-plot-demo2.png]] But Matlab command "cd" does not work correctly in upper code method. Currently I come up with two solutions: solution 1 #+begin_src matlab :results graphics file link :file "data/images/matlab-plot-demo2.png" :session "*MATLAB*" :var img="data/images/matlab-plot-demo2.png" bar([1 11 7 8 2 2 9 3 6]) % saveas(gcf, 'data/images/matlab-plot-demo2.png') % saveas(gcf, img) disp(img) close(gcf) #+end_src #+RESULTS[(2023-04-13 12:08:35) b87e1d8687e33acc089ea7374829c4d41e3dd0e4]: [[file:data/images/matlab-plot-demo2.png]] solution 2 #+headers: :var cwd=(expand-file-name "data/images/" (file-name-directory (buffer-file-name))) #+headers: :prologue "eval(sprintf("cd '%s'", cwd))" #+headers: :epilogue "saveas(gcf,'matlab-plot-demo2.png'); close(gcf);" #+begin_src matlab :results graphics file link :dir "data/images" :file "matlab-plot-demo2.png" :session "*MATLAB*" bar([1 11 7 8 2 2 9 3 6]) #+end_src #+RESULTS[(2023-04-13 00:09:01) c5fc0d36b27e75610664ee69ae618649637e45d9]: [[file:data/images/matlab-plot-demo2.png]] Both does not work. If you got a workable solution, please help me, Thanks very much. [stardiviner] GPG key ID: 47C32433IRC(freeenode): stardiviner Twitter: @numbchildKey fingerprint = 9BAA 92BC CDDD B9EF 3B36 CB99 B8C4 B8E5 47C3 2433Blog: http://stardiviner.github.io/