[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Arrays of strings

**From**: |
Ted Harding |

**Subject**: |
Arrays of strings |

**Date**: |
Sun, 3 Sep 1995 20:33:06 +0200 (BST) |

Hi All,
Am I missing something?
I want to set up an array of strings (actually a list of filenames which I
want octave to work through, to be given one by one as string arguments to
a function).
In Matlab this is straightforward, if bulky: a string can be stored as a
vector of floats, one for the ASCII code of each character, and a matrix
can be constructed of which each row is the sequence of numbers for the
ASCII characters of a string (you would have to pad some strings with
spaces to make them all the same length).
In Matlab you could write
names = ['file1'; 'file2'];
or
names = ['file1'
'file2' ];
and get the i-th names as names(i,:).
I can not find any way of doing such a thing in octave. Construction as
above generates an error. The function "abs" in Matlab returns the ASCII
numerical codes: abs('file1') = [102 105 108 101 49]. This also generates
an error in octave (otherwise could be used to make a numerical matrix).
Although octave has conversions going the other way (num2str, int2str),
there seem to be no way to set up an array of strings, or even to get at
individual elements of a string.
Can anyone help?
Ted. (address@hidden)

**Arrays of strings**,
*Ted Harding* **<=**