From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id AMquDv+MN2RM/gAASxT56A (envelope-from ) for ; Thu, 13 Apr 2023 07:02:55 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id AHDDDf+MN2RhdAAAG6o9tA (envelope-from ) for ; Thu, 13 Apr 2023 07:02:55 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id B23C11A6E1 for ; Thu, 13 Apr 2023 07:02:54 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pmp6L-0003bx-Np; Thu, 13 Apr 2023 01:02:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pmp6J-0003Zw-Eg for emacs-orgmode@gnu.org; Thu, 13 Apr 2023 01:02:27 -0400 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pmp6H-0005DX-G8 for emacs-orgmode@gnu.org; Thu, 13 Apr 2023 01:02:27 -0400 Received: by mail-pj1-x1033.google.com with SMTP id 98e67ed59e1d1-2465e4f1954so1119535a91.0 for ; Wed, 12 Apr 2023 22:02:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681362144; x=1683954144; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=fDxRKTuPYy8HcohisWGqyx49vtWT8kHq+4ev1KjzsvQ=; b=FtlS2gF79acrxvj9NbM0Ut47eEvOmPmC5o7PgtLC+3b3zktkW653CXh/iEI//Mamth JKVouXvgR+ZMJkvMPND5N+sBFqa9brtDfE6QFF7VQ1JrICXFFtTLbAZ+VJchpUGaMM9d 3sWwkjg4U/ofSXacrkGFbBGj60Ui9T3ri1vX5nteEo9uC83wTXlFwIWvmxtwFz3b4O3p UnkZ7rOZYFBjDbe2OFHActHfRazqn/YOsbcqTQbz1JTnJxIQgPA4z89tDbK/bxAKVnhq lz5tpe3FNLzBbHGmXTChft4S6fTgapRDYxwoNQXu3isiw9xBOxrK9GrqbwZq6B0KYA6b 2OaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681362144; x=1683954144; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=fDxRKTuPYy8HcohisWGqyx49vtWT8kHq+4ev1KjzsvQ=; b=jpNFvFrHlmHtvNNJHEQ9tFNenMXKoB7ZTDiwINzUIsY9pxwabCV1CloY2YFDkC7QFc pfn8iFXM+wWBAlg3YbX5jThQWQYObi73J4CsaFGuLGnSPasvQtwhYFO5Z7WyQmMzdRTR riYWyzdx0eYfbxLW8hIfHTRQseWY2SOlhzIMyLpT83dSbamh/XjFNpXeJeITYLfyXCeR G1YUpx8TUyVzoCEi80y+d9lmRiuUXKnuYX5EJrOV3iugyJL1yQ4jaQjXr5Ol29QCo2im Z/d1d2wQGPuW2HoVRC7CQ9Wq9amtnVUCVDZj8wIlYowOQaIe29ndZOeVaKnHPDY6XXqH XrSA== X-Gm-Message-State: AAQBX9c298D36/+WxVrgSafD+izsCFPsn7aA/i/dmZPwh82s8y5Pg80C CVsr74LnLZqCSnWbhbmkhdNiu0ZliIgWUgQUoVhlCZJjEyz5t4g= X-Google-Smtp-Source: AKy350bwv6ysq3KiVBBG3ZrDKMh7/Dh1yKkXPSsLujzGXjA2ARk9qUmHWqryn0+jJem2eu2lNqSeZ75VuS7l0cduSaM= X-Received: by 2002:a05:6a00:2d94:b0:637:ec79:5afc with SMTP id fb20-20020a056a002d9400b00637ec795afcmr594251pfb.3.1681362143704; Wed, 12 Apr 2023 22:02:23 -0700 (PDT) MIME-Version: 1.0 From: stardiviner Date: Thu, 13 Apr 2023 13:01:57 +0800 Message-ID: Subject: How to change working directory in ob-matlab source block? To: Org-mode Content-Type: multipart/alternative; boundary="000000000000507cb205f930a167" Received-SPF: pass client-ip=2607:f8b0:4864:20::1033; envelope-from=numbchild@gmail.com; helo=mail-pj1-x1033.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Seal: i=1; s=key1; d=yhetil.org; t=1681362175; a=rsa-sha256; cv=none; b=tODVK5jEmO4wKECu4Uz9xpjEQlCjBV18utVdPjSo5AJ+N+P2ly4nAaSJenEKjuefe5zRPR TFMwEiMxrI3QaKgYC+gbSdWieG6UT7vAcrKaSAqBxYCnFFhccl8pOpVkiZDv9jVZzN3r/q PbGEFtkZjFN+HPpBnlX1srwsfQwkZ35rPkzEFHupwHy11GAnTURi0kNIAxoft4fivKkbhv dSqPDfmLP+uDPBxJxlMnXHSrecTYK095ByU4j+pC3/sK4VTyplIoAjGYQoI4VhH4O1/a01 czQ3yepTiYK5dnOleqWFh3DQWGEABcDKidcvx67+2VjVRvjmZozuoAwwQxO0/A== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=FtlS2gF7; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1681362175; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=fDxRKTuPYy8HcohisWGqyx49vtWT8kHq+4ev1KjzsvQ=; b=HYuYrha9VyivCIioF9WkjhZVll1Nv4pjA7OtQlGQsqf0b1X2lEJLE5wa4+qo6e/ZEOs5Ue KirF7iiPkjWguqOmN5WERbkYyCSg+TF3kWhJHblK07/NARYGUCv/ZyQoiZT5UtMus3JCpy A18wUvG7d+b+IYVe+r++JVzRr/1hlrYACotfzfKgbkxPKhgHRT1k/Xj7r/KTtbRVGZLDmL 3hHH4CtQt3EVz2f5Qa4Wy0E/erTfCpTHZmylCyR+JgCRytG1teOFnbu+x/CdCC4r69i1o3 PtnZnXrLJSj6VvjYA+ZGsSOIJIq+BercjU2jvni67Yw8dq8mPuZxOOdFmP9bKA== X-Migadu-Queue-Id: B23C11A6E1 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=FtlS2gF7; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gmail.com X-Migadu-Scanner: scn0.migadu.com X-Migadu-Spam-Score: -5.95 X-Spam-Score: -5.95 X-TUID: hsV1Vug9D7Nq --000000000000507cb205f930a167 Content-Type: text/plain; charset="UTF-8" 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/ --000000000000507cb205f930a167 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Is there friend know Emacs Org mode and Matlab here?<= /div>
I try to save Matlab plot into image file in another path ins= tead of current working directory. Like
bellowing code:

=
#+headers: :var cwd=3D(expand-file-name "data/images/" (file= -name-directory (buffer-file-name)))
#+headers: :prologue "e= val(sprintf("cd '%s'", cwd))"
#+headers: := epilogue "saveas(gcf,'matlab-plot-demo2.png'); close(gcf);&quo= t;
#+begin_src matlab :results graphics file link :dir "data= /images" :file "matlab-plot-demo2.png" :session "*MATLA= B*"
bar([1 11 7 8 2 2 9 3 6])
#+end_src

<= div>#+RESULTS[(2023-04-13 00:09:01) c5fc0d36b27e75610664ee69ae618649637e45d= 9]:
[[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:

soluti= on 1

#+begin_src matlab :results graphics file link :file &qu= ot;data/images/matlab-plot-demo2.png" :session "*MATLAB*" :v= ar img=3D"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) b87e= 1d8687e33acc089ea7374829c4d41e3dd0e4]:
[[file:data/images/matlab-= plot-demo2.png]]

solution 2

#+headers: :var cwd= =3D(expand-file-name "data/images/" (file-name-directory (buffer-= file-name)))
#+headers: :prologue "eval(sprintf("cd = 9;%s'", cwd))"
#+headers: :epilogue "saveas(gc= f,'matlab-plot-demo2.png'); close(gcf);"
#+begin_src= matlab :results graphics file link :dir "data/images" :file &quo= t;matlab-plot-demo2.png" :session "*MATLAB*"
bar([= 1 11 7 8 2 2 9 3 6])
#+end_src

#+RESULTS[(2023-04-1= 3 00:09:01) c5fc0d36b27e75610664ee69ae618649637e45d9]:
[[file:dat= a/images/matlab-plot-demo2.png]]

Both does not work.
If you got a workable solution, please help me, Thanks very much.
[stardiviner]=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 <Hack this world!>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 GPG key ID= : 47C32433IRC(<span zeum4c4=3D"PR_2_0" data-ddnwab=3D"PR_= 2_0" aria-invalid=3D"spelling" class=3D"LI ng">= freeenode</span>): stardiviner =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 Twitter:=C2=A0 @numbchildKey fingerprint =3D 9BAA 92BC CDDD B9EF 3B36= =C2=A0 CB99 B8C4 B8E5 47C3 2433Blog: <a href=3D"http://stardiviner.github.io/" target=3D&qu= ot;_blank">http://stardiv= iner.github.io/</a>





--000000000000507cb205f930a167--