From mboxrd@z Thu Jan 1 00:00:00 1970 From: Neil Jerram Subject: Re: babel, matlab export plot to png fails Date: Tue, 15 Aug 2017 11:12:40 +0200 Message-ID: <5678702d-9fdc-74ff-443c-fa979185ffca@ossau.homelinux.net> References: <87shgveujl.fsf@mat.ucm.es> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:37207) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dhXu4-0000za-GN for emacs-orgmode@gnu.org; Tue, 15 Aug 2017 05:12:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dhXu0-0001Lm-G7 for emacs-orgmode@gnu.org; Tue, 15 Aug 2017 05:12:48 -0400 Received: from smtp-out-2.talktalk.net ([62.24.135.66]:47275) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dhXu0-0001Ko-Ar for emacs-orgmode@gnu.org; Tue, 15 Aug 2017 05:12:44 -0400 Received: from [192.168.1.103] (AToulouse-655-1-41-5.w90-60.abo.wanadoo.fr [90.60.95.5]) by arudy.520b.com (Postfix) with ESMTPSA id A593E380D3 for ; Tue, 15 Aug 2017 10:02:57 +0100 (BST) In-Reply-To: <87shgveujl.fsf@mat.ucm.es> Content-Language: en-US List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org On 13/08/17 10:33, Uwe Brauer wrote: > Hi > > I would like to execute some matlab code in org file (using GNU emacs 26 > and the git version of org mode) and save the result of the plot command > in a png file, so I tried > > #+begin_src matlab :session :exports both :file testplot.png > t=[0:0.1:1]; > y=sin(t); > plot(t,y) > print -dpng testplot.png > #+end_src > > And also > #+begin_src matlab :results output latex :exports results :file testplot.png > t=[0:0.1:1]; > y=sin(t); > plot(t,y) > print -dpng testplot.png > #+end_src > > But the resulting png files are corrupt. I presume also the matlab > commands are included in the png file which is not correct. But I don't > know who to achieve that just the last command is saved in a png file. I guess the problem is that the Matlab line "print -dpng testplot.png" is correctly writing the plot to testplot.png, as you want, but then org-mode is overwriting that file because of the ":file testplot.png". I would try deleting ":file testplot.png". The meaning of ":results output" may be a bit language-dependent - I don't know org-mode well enough to be sure about that yet - but in general I would expect it to consist of the standard output of those commands. So, for example, if you type "print -dpng testplot.png" and Matlab responds with "Generated 'testplot.png'", I would expect ":results output" to contain "Generated 'testplot.png'", not the PNG data. Regards - Neil