Hi, I posted a first thread but can't find it anywhere, so I probably
messed up somewhere. So here is my problem: let's say we have following
arrays:
B = [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]
E =[5 5 5 4 5 5 5 5 1 5]
If we do this:
B[E]
we get:
B[E]
1x10 Array{Int64,2}:
11 11 11 10 11 11 11 11 17 11
No problems. But how would I do that for all columns of B? In matlab, I'd
do this: B(E,:) and get:
ans =
11 18 25 2 9
11 18 25 2 9
11 18 25 2 9
10 12 19 21 3
11 18 25 2 9
11 18 25 2 9
11 18 25 2 9
11 18 25 2 9
17 24 1 8 15
11 18 25 2 9
In Julia I must do a loop:
S = zeros(10,5)
x = [1 2 3 4 5]
for i in x
S[:,i] = B[:,i][E[end,:]]
end
Is there a way to avoid this loop and obtain something like in Matlab using
simple indexing notation?