From: d.tchin <d.tchin@voila.fr>
To: emacs-orgmode@gnu.org
Subject: Re: [BABEL] Output with octave [PATCH]
Date: Wed, 4 Aug 2010 15:15:18 +0000 (UTC) [thread overview]
Message-ID: <loom.20100804T170447-481@post.gmane.org> (raw)
In-Reply-To: 87aap3roxn.fsf@stats.ox.ac.uk
Dan Davison <davison <at> 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---
next prev parent reply other threads:[~2010-08-04 15:15 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-23 16:59 [BABEL] Output with octave d.tchin
2010-07-23 23:12 ` Eric S Fraga
2010-07-26 14:25 ` d.tchin
2010-08-01 18:18 ` Dan Davison
2010-08-01 20:07 ` Re: [BABEL] Output with octave + [PATCH] x2 Juan
2010-08-01 20:22 ` Re: [BABEL] Output with octave [PATCH] Juan Pechiar
2010-08-04 4:18 ` Dan Davison
2010-08-04 15:15 ` d.tchin [this message]
2010-08-01 22:19 ` [BABEL] Output with octave + [PATCH] x2 Dan Davison
2010-08-01 22:55 ` [BABEL] Octave issues Juan
2010-08-01 23:32 ` Dan Davison
2010-08-02 9:30 ` [BABEL] Output with octave d.tchin
2010-08-04 4:15 ` Dan Davison
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=loom.20100804T170447-481@post.gmane.org \
--to=d.tchin@voila.fr \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).