Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我有:
>> X = magic(5) X = 17 24 1 8 15 23 5 7 14 16 4 6 13 20 22 10 12 19 21 3 11 18 25 2 9
如何从第二列中获取第 i 个元素?
我已经发现 Octave 中(一些?)集合中的索引是基于 1 的,但我不确定这是否也适用于矩阵。
请参阅手册的索引表达式部分。要从第二列获取第 i 个元素:
X(i,2) # element 'i' from column 2 X(1:end,2) # the whole 2nd column X(:,2) # same thing but shorter x(:, [2 3]) # whole 2nd and 3rd column
请注意,Octave 是一种数组元素按列优先顺序排列的语言。