我有 6 -by- 3 矩阵作为 1,0,0.01
2,1,0.03
2,0,0.04
3,1,0.06
3,2,0.05
3,3,0.07
文件,例如:
A
哪些列分别指代Z
,D
和A
。
我想要一个Matlab代码,当我写Z
和D
时,它会写sample(3,2)
。
例如,当我写0.05
时,它给了我0
而不是>>> col1 = ['a. w','b. y','c. x']
>>> col2 = ['a. w','b. y','c. x']
>>> df=[col1,col2]
>>> result = []
>>> for x in df : result.append(map(lambda y : y[3:],x))
>>> result
[['w', 'y', 'x'], ['w', 'y', 'x']]
答案 0 :(得分:1)
根据Dan的评论,这是一种方法。
首先我们从文件中加载数据:
foreach ($pdo->query($sql) as $row) {
$array[$row['name']] = $row['name'];
}
接下来,为方便起见,我们创建了一个匿名函数:
>> load -ascii sample.txt
>> sample
sample =
1.0000 0 0.0100
2.0000 1.0000 0.0300
2.0000 0 0.0400
3.0000 2.0000 0.0700
4.0000 2.0000 0.0600
4.0000 3.0000 0.0500
现在我们可以访问以下值:
>> D = @(A,Z) sample(ismember(sample(:,1:2), [A,Z], 'rows'), 3);