From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id cO65MmqVN2THBQEASxT56A (envelope-from ) for ; Thu, 13 Apr 2023 07:38:50 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id IIyUMmqVN2SW7AAAauVa8A (envelope-from ) for ; Thu, 13 Apr 2023 07:38:50 +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 7C8509FA8 for ; Thu, 13 Apr 2023 07:38:50 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pmpek-0002xF-GP; Thu, 13 Apr 2023 01:38:02 -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 1pmped-0002wy-SY for emacs-orgmode@gnu.org; Thu, 13 Apr 2023 01:37:55 -0400 Received: from [39.171.214.146] (helo=Mac-mini.local) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pmpeb-0003YI-HM for emacs-orgmode@gnu.org; Thu, 13 Apr 2023 01:37:55 -0400 Received: by Mac-mini.local (Postfix, from userid 501) id C702E8734708; Thu, 13 Apr 2023 13:37:44 +0800 (CST) References: User-agent: mu4e 1.10.2; emacs 30.0.50 From: "Christopher M. Miles" To: Org-mode Subject: [SOLVED] Re: How to change working directory in ob-matlab source block? Date: Thu, 13 Apr 2023 13:35:30 +0800 In-reply-to: Message-ID: MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-Host-Lookup-Failed: Reverse DNS lookup failed for 39.171.214.146 (deferred) Received-SPF: softfail client-ip=39.171.214.146; envelope-from=numbchild@gmail.com; helo=Mac-mini.local X-Spam_score_int: 58 X-Spam_score: 5.8 X-Spam_bar: +++++ X-Spam_report: (5.8 / 5.0 requ) BAYES_00=-1.9, DKIM_ADSP_CUSTOM_MED=0.001, FORGED_GMAIL_RCVD=1, FREEMAIL_FROM=0.001, MSGID_MULTIPLE_AT=1, NML_ADSP_CUSTOM_MED=0.9, RCVD_IN_PBL=3.335, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665, SPOOFED_FREEMAIL_NO_RDNS=0.001 autolearn=no autolearn_force=no X-Spam_action: reject 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: , Reply-To: numbchild@gmail.com 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=1681364330; a=rsa-sha256; cv=none; b=KB/Hb5fjXuDjuZT1doDDBWvxPbEqMqTJtNCbw3EK7orWOwFXsVX+aRQCIXY3CNFE5MNAnk 0ybVLDYUAvIdzvL75Kheb5DvOXTU/a21GEFWKcD3Nrza4TsWd4sYYZ9EQENU5fMYxaP/w7 PR4YLaIQOJKGJwnZddyFZPf+zUvQzP966uMzk5wbJYoQ3629rlSsqhzpRUktHhnTVIoA89 P9s1e94gLGtIt5Lt6n5DBmCG/eR1iUQaBtJNJIOiuwfzGF3rM2YLMKbD05DAnGp/p3dpjG i0GlF8t7vJ+Xs2LPWMbFY2/kxsEIMYHjBYukjTio1Llr3O0pVitOQvTRaZEFlA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; 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=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmail.com (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1681364330; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=YJ0lGgQhHmheCUKC2N3VuRmGvYcNBS6XWusLeW10l/w=; b=Ho/xyiKNWvCZ4lTgxfidlSbpSS3LHpdbwI4nheVENRBRup9WE0ijp/yJkqINZkABZ/WoyI TMPGhHJ62Nmum+Ot7KGSRnPvMtnipGJdNaXihARY/sRM21zkMRdBMXAi0mZDNXn7VGx4Li Bq4Q1evmqaHyE65HJuGZNZI9s6nG6hOPufmpc78g4xuX7FUdhok3+folSjMKsvsyXF6RDd rT4fUMJ1Cb655ZVt1LBKCpAXRBZggKCcLJFnVHSD3WtooQIZpyeX3iemwiUt5Q2T5OHVAv Nopf8cmzu1mk7xpJjIntBFXPdTxuQH0tc7Q3q7Xo8RoEf4kSj1Ie0TNeuoDSqA== X-Migadu-Queue-Id: 7C8509FA8 Authentication-Results: aspmx1.migadu.com; dkim=none; 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=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmail.com (policy=none) X-Migadu-Scanner: scn0.migadu.com X-Migadu-Spam-Score: 2.38 X-Spam-Score: 2.38 X-TUID: d7v2TWY7FVlI --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable stardiviner writes: > Is there friend know Emacs Org mode and Matlab here? > > I try to save Matlab plot into image file in another path instead of curr= ent working directory. Like > bellowing code: > > #+headers: :var cwd=3D(expand-file-name "data/images/" (file-name-directo= ry (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. > I find out the solution. The "cd" command used as a function then pass in path string as argument. It works fine. So I adopt source block like this: #+headers: :var cwd=3D(expand-file-name "data/images/" (file-name-directory= (buffer-file-name))) #+headers: :prologue "cd(cwd)" #+begin_src matlab :session "*MATLAB*" :results output % eval(sprintf("cd '%s'", cwd)) % eval(sprintf("cd('%s')", cwd)) % cd(cwd) % returns the path to the current working directory. pwd #+end_src #+RESULTS[(2023-04-13 13:20:27) 0c1259b084fc93f95d7c60c9c748a0630bf4391d]: #+begin_example cd(cwd) cwd=3D'/Users/stardiviner/Org/Wiki/Computer Technology/Programming/Emacs/Em= acs Packages/Org mode/data/images/'; % eval(sprintf("cd '%s'", cwd)) % eval(sprintf("cd('%s')", cwd)) % cd(cwd) % returns the path to the current working directory. pwd ans =3D '/Users/stardiviner/Org/Wiki/Computer Technology/Programming/Emacs/Emac= s Packages/Org mode/data/images' #+end_example Really tricky for me. Hope helpful for some user. =2D-=20 [ stardiviner ] I try to make every word tell the meaning that I want to express without mi= sunderstanding. Blog: https://stardiviner.github.io/ IRC(libera.chat, freenode): stardiviner, Matrix: stardiviner GPG: F09F650D7D674819892591401B5DF1C95AE89AC3 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAmQ3lSQACgkQG13xyVro msOHXAgAxYeXceHndiJIFvnYGWC9ONJf4fkuZMjWWr/n98LaMRLqh9HlRwd7754j gj8K6K60JptkKzEe8yUIwXsZ3UpB0AuQo7jeg+3xnvvf7tVOnqQezvk38dWl46CM RrFtNv1EetxxiFB7rfEYgTldz7I6gGXKFWiSOvNDyvK8CUeq2p/jzOsBQu5iY9jE PVNZE3qa/gfhYJOsmyG6EDVWmYeZXLRtMtc1zDSAKvz8AB/XwkdIPn7LUmzs18Sg XxACYmFjrFrJ4vIg7yKYhPlJBb3ZIF/P1ujkkGFWt1zbZgHse+aTEKp3NjmTo7yN P9AyWvGKr5AA5vInasXv6DMtdN2kXQ== =pDa8 -----END PGP SIGNATURE----- --=-=-=--