From mboxrd@z Thu Jan 1 00:00:00 1970 From: Darlan Cavalcante Moreira Subject: Re: Re: org-babel matlab example Date: Sun, 12 Sep 2010 11:58:28 -0300 Message-ID: <4c8e1c34.14c2640a.1e85.21cc@mx.google.com> References: <20100911.101806.1287597470496846955.etimecowboy@gmail.com> <87iq2c2t9t.fsf@stats.ox.ac.uk> <87iq2c2qru.fsf@stats.ox.ac.uk> <20100912.084540.2128491266708771935.etimecowboy@gmail.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Return-path: Received: from [140.186.70.92] (port=55195 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ov8Mo-00006x-U8 for emacs-orgmode@gnu.org; Mon, 13 Sep 2010 08:42:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Ov8Mi-0004HU-Fn for emacs-orgmode@gnu.org; Mon, 13 Sep 2010 08:42:38 -0400 Received: from mail-gw0-f41.google.com ([74.125.83.41]:42208) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Ov8Mi-0004HB-Ak for emacs-orgmode@gnu.org; Mon, 13 Sep 2010 08:42:32 -0400 Received: by gwj16 with SMTP id 16so2659539gwj.0 for ; Mon, 13 Sep 2010 05:42:31 -0700 (PDT) In-Reply-To: <20100912.084540.2128491266708771935.etimecowboy@gmail.com> 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: etimecowboy Cc: davison@stats.ox.ac.uk, emacs-orgmode@gnu.org Can I leave a suggestion here? Maybe a header argument ,---- | :return variableName `---- could be interesting in org babel. This would make babel behavior more uniform in all supported languages and avoid the necessity of adding code "only to make babel work". -- Darlan At Sun, 12 Sep 2010 08:45:40 +0100 (BST), etimecowboy wrote: > > 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' > ~^^~ > > _______________________________________________ > 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