From mboxrd@z Thu Jan 1 00:00:00 1970 From: d.tchin Subject: Re: [BABEL] Output with octave [PATCH] Date: Wed, 4 Aug 2010 15:15:18 +0000 (UTC) Message-ID: References: <87iq45x06e.wl%ucecesf@ucl.ac.uk> <871vai42nz.fsf@stats.ox.ac.uk> <20100801200727.GT5569@soloJazz.com> <20100801202214.GU5569@soloJazz.com> <87aap3roxn.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=44691 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ogfgr-0004NR-Rt for emacs-orgmode@gnu.org; Wed, 04 Aug 2010 11:15:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Ogfgq-0006xo-2u for emacs-orgmode@gnu.org; Wed, 04 Aug 2010 11:15:33 -0400 Received: from lo.gmane.org ([80.91.229.12]:54634) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Ogfgp-0006xS-Mw for emacs-orgmode@gnu.org; Wed, 04 Aug 2010 11:15:32 -0400 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1Ogfgl-0002AE-T1 for emacs-orgmode@gnu.org; Wed, 04 Aug 2010 17:15:28 +0200 Received: from APuteaux-754-1-24-6.w90-44.abo.wanadoo.fr ([90.44.7.6]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 04 Aug 2010 17:15:27 +0200 Received: from d.tchin by APuteaux-754-1-24-6.w90-44.abo.wanadoo.fr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 04 Aug 2010 17:15:27 +0200 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: emacs-orgmode@gnu.org Dan Davison stats.ox.ac.uk> writes: > > Hi Juan and d.tchin, > > One thing I'd like to ask for advice about is the behaviour of tabular > data structures containing strings. For example > > #+begin_src octave > ans = [['a','b'];['c','d']] > #+end_src > > #+results: > : acbd > > I don't know if my syntax above is correct, but it seems to me that this > is a 2x2 table of some sort and so it would seem natural to me for that > to return > > | a | b | > | c | d | > > however, if you look at the code we are using below, you'll see that > ischar() returns 1 for this object and so it gets written as a > string. Can you suggest how we should alter the octave/matlab code > below? Or perhaps people don't use tabular data structures containing > strings in these languages? > > if ischar(ans), fid = fopen('%s', 'w'); fprintf(fid, '%%s\\n', ans); fclose (fid); > else, dlmwrite('%s', ans, '\\t') > end" > > Dan > I use typeinfo defined in Octave to see what kind of object Octave would consider as output. You can see that [["a',"b"];["c","d"]] is considered as string and not a matrix. And the output in Octave is ans = ab cd See tests below done with character and number. Hope that can help. --8<---------------cut here---------------start------------->8--- * Output typeinfo ** Character #+begin_src octave typeinfo("a") #+end_src #+results: : string #+begin_src octave ["c","d"] #+end_src #+results: : cd #+begin_src octave [["a","b"];["c","d"]] #+end_src #+results: : acbd #+begin_src octave typeinfo([["a","b"];["c","d"]]) #+end_src #+results: : string ** Number #+begin_src octave typeinfo(1) #+end_src #+results: : scalar #+begin_src octave [1,2] #+end_src #+results: : 1.00000000e+000 2.00000000e+000 #+begin_src octave typeinfo([1,2]) #+end_src #+results: : matrix #+begin_src octave ([[1,2];[3,4]]) #+end_src #+results: : 1.00000000e+000 2.00000000e+000 : 3.00000000e+000 4.00000000e+000 #+begin_src octave typeinfo([[1,2];[3,4]]) #+end_src #+results: : matrix --8<---------------cut here---------------end--------------->8---