From mboxrd@z Thu Jan 1 00:00:00 1970 From: etimecowboy Subject: Re: org-babel matlab example Date: Sun, 12 Sep 2010 08:45:40 +0100 (BST) Message-ID: <20100912.084540.2128491266708771935.etimecowboy@gmail.com> References: <20100911.101806.1287597470496846955.etimecowboy@gmail.com> <87iq2c2t9t.fsf@stats.ox.ac.uk> <87iq2c2qru.fsf@stats.ox.ac.uk> Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Return-path: Received: from [140.186.70.92] (port=32887 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OuhG4-0005wJ-1N for emacs-orgmode@gnu.org; Sun, 12 Sep 2010 03:45:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OuhG2-0002ht-My for emacs-orgmode@gnu.org; Sun, 12 Sep 2010 03:45:51 -0400 Received: from mail-ww0-f41.google.com ([74.125.82.41]:65337) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OuhG2-0002hn-HV for emacs-orgmode@gnu.org; Sun, 12 Sep 2010 03:45:50 -0400 Received: by wwe15 with SMTP id 15so688949wwe.0 for ; Sun, 12 Sep 2010 00:45:49 -0700 (PDT) In-Reply-To: <87iq2c2qru.fsf@stats.ox.ac.uk> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: davison@stats.ox.ac.uk Cc: etimecowboy@googlemail.com, emacs-orgmode@gnu.org From: Dan Davison Subject: Re: org-babel matlab example Date: Sat, 11 Sep 2010 12:23:17 -0400 > Dan Davison writes: > >> etimecowboy writes: >> >>> Hi everybody, >>> >>> I am learning to use org-babel to evaluate in-line Matlab code block, >>> but I cannot make it works when I press the "C-c C-c", nor "C-c C-v >>> e". >> >> What happens when you try C-c C-c or C-c C-v e ? There is an issue with >> matlab and octave: they return the value of the last /unassigned/ >> computation > > A better way to say this is: they return the value of the special > variable "ans". So whatever you do, at the end of the block you need to > ensure that "ans" has the value that you want returned. > > I've updated the Worg page on Matlab and Octave: > > http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-octave-matlab.php > > Dan > > >>, so simply ending the code block with a variable name "x" is >> not enough. Could you try one of the following schemes please, and let >> us know if that solves it: >> >> #+begin_src matlab :exports results >> n = [1:10]; >> x = 5*n+4; >> ans = x >> #+end_src >> >> #+begin_src matlab :exports results >> n = [1:10]; >> x = 5*n+4; >> x + 0 >> #+end_src >> >> >>> The export of code works, but the results was not there. My in-line code is like this: >> >> There was a little typo in your original block: the keyword is >> ":exports" with an s. >> >> Dan >> >>> >>> #+begin_src matlab :export results >>> n = [1:10]; >>> x = 5*n+4; >>> x >>> #+end_src >>> >>> Is there someone can provide me a working example? Thanks a lot. >>> >>> >>> ----------------------------- >>> >>> etimecowboy@gmail.com >>> >>> _.,----,._ >>> .:' `:. >>> .' `. >>> .' `. >>> : : >>> ` .'`':'`'`/ ' >>> `. \ | / ,' >>> \ \ | / / >>> `\_..,,.._/' >>> {`'-,_`'-} >>> {`'-,_`'-} >>> {`'-,_`'-} >>> `YXXXXY' >>> ~^^~ >>> >>> _______________________________________________ >>> Emacs-orgmode mailing list >>> Please use `Reply All' to send replies to the list. >>> Emacs-orgmode@gnu.org >>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode >> >> _______________________________________________ >> Emacs-orgmode mailing list >> Please use `Reply All' to send replies to the list. >> Emacs-orgmode@gnu.org >> http://lists.gnu.org/mailman/listinfo/emacs-orgmode Dear Dan, I have checked the Worg page you updated and tried your example. It works! The ans variable is the secret! Thanks a lot. I suggest org should provide some examples in its user's guide, not only on the topic of Babel but also Table, Hyperlink, Picture, and etc. ----------------------------- etimecowboy@gmail.com _.,----,._ .:' `:. .' `. .' `. : : ` .'`':'`'`/ ' `. \ | / ,' \ \ | / / `\_..,,.._/' {`'-,_`'-} {`'-,_`'-} {`'-,_`'-} `YXXXXY' ~^^~