从 GNU Octave 中的字符串数组访问字符串

Arc*_*ahi 4 string octave

如何访问整个元素helloahoy八度?仅打印每个字符串中的第一个字符。

octave:1> s = ["hello";"ahoy"]
s =

hello
ahoy 

octave:2> s(1)
ans = h
octave:3> s(2)
ans = a
Run Code Online (Sandbox Code Playgroud)

Tas*_*nou 8

请改用元胞数组。

octave:1> s = { 'hello'; 'ahoy' };

octave:2> s{1}
ans = hello

octave:3> s{2}
ans = ahoy
Run Code Online (Sandbox Code Playgroud)

https://octave.org/doc/v5.2.0/Cell-Arrays.html#Cell-Arrays