help-octave
[Top][All Lists]
Advanced

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

String Array


From: John W. Eaton
Subject: String Array
Date: Sat, 20 Nov 2010 02:04:20 -0500

On 19-Nov-2010, stoucha wrote:

| 
| Hi.
| 
| I would like to create an array of strings such that I can reference them
| similar to referencing values in a matrix.
| 
| Here is what I have tried:
| 
| a = ["string1"; "string2"; "string3"];
| 
| when I type "a" at an octave prompt I get three lines as follows
| string1
| string2
| string3
| 
| however, if I type a(1) in an attempt to get just "string1" I just get "s"
| 
| Any ideas how to achieve an array of strings where I can reference each
| element individually.

You created a character matrix.

Try using a cell array of strings, like this:

  a = {"string1"; "string2"; "string3"};
  a{1}

jwe


reply via email to

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