help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Arrays of strings


From: John Eaton
Subject: Re: Arrays of strings
Date: Wed, 6 Sep 1995 17:37:54 -0500

address@hidden <address@hidden> showed how
to simulate vectors of strings using numeric matrices and
toascii/setstr:

: Here's what I did I wrote a tiny function stostr:
: 
: function var = stostr(var, loc, string)
: var(loc,1:max(size(toascii(string)))) = toascii(string);

Yes, this is about the best you can do with 1.1.1.  For 1.2, Octave
will support vectors of strings.  Indexing will work as will
conversion to numeric matrices using toascii (or abs, if
implicit_str_to_num_ok is set is set to true).

Also, the internal representation will be 1-byte characters, not be a
matrix of doubles, so strings should be more space-efficient in Octave
compared to Matlab, and Octave will not force to to pad strings to
the same length in order to put them in an array.  For example,

  foo = ["this"; "is"; "an"; "array"; "of"; "strings"]

will be perfectly acceptable.

Thanks,

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]