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---







_______________________________________________
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

Reply via email to