如何在Julia中找到矩阵索引?

时间:2019-07-09 19:15:05

标签: julia

如何达到矩阵的索引。例如:

 m
3×5 Array{Int64,2}:
 1  2  1  2  3
 1  2  3  1  2
 2  2  2  2  0

is the matrix. for accessing indices in first row these functions used. 

s=ind2sub(m,find( x -> x == 1, m[:,1] ))
([1, 2], [1, 1])

but for 2
s=ind2sub(m,find( x -> x == 2, m[:,1] ))
([3], [1])

it didn't find the fist 2 in indices[1,2]

and also for 3

julia> s=ind2sub(m,find( x -> x == 3, m[:,1] ))
(Int64[], Int64[])

there was not any indices. 
for more explanation 
indices are need to make y. y is made from m that is included binary elements. y[i=1:5,k=1:3,t=1:3]
y[:,:,1]=[1 0 0;0 1 0;1 0 0;0 1 0;0 0 1]
y[:,:,2]=[1 0 0;0 1 0;0 0 1;1 0 0;0 1 0]
y[:,:,3]=[0 1 0;0 1 0;0 1 0;0 1 0;0 0 0]

请您帮助我如何获得正确的指数。 非常感谢。

0 个答案:

没有答案