使用其中包含字符串的列表初始化矩阵
Initializing a matrix using a list with a string in it
这是我的代码:
extensions [matrix]
..
sources-own[keyword1 keyword2 keyword3 keyword4 extrinsic-fitness visits]
..
to setup
create-sources
ask source 0 [
set keyword1 (matrix:from-row-list [["cat"][2]])
]
...
..
.
现在,当我点击 SETUP 并检查 "source 0" 时,它显示要初始化的矩阵如下:
{{matrix: [ [ 0 ][ 2 ] ]}}
尽我所能,我无法让它接受字符串 "cat" 代替第一列中的“0”。
好的,我知道了。
Netlogo 中的矩阵只能容纳数字。需要使用 "list" 来代替。
这是我的代码:
extensions [matrix]
..
sources-own[keyword1 keyword2 keyword3 keyword4 extrinsic-fitness visits]
..
to setup
create-sources
ask source 0 [
set keyword1 (matrix:from-row-list [["cat"][2]])
]
...
..
.
现在,当我点击 SETUP 并检查 "source 0" 时,它显示要初始化的矩阵如下:
{{matrix: [ [ 0 ][ 2 ] ]}}
尽我所能,我无法让它接受字符串 "cat" 代替第一列中的“0”。
好的,我知道了。
Netlogo 中的矩阵只能容纳数字。需要使用 "list" 来代替。