# How to get linear indices of array along a slice k?

**URL:** <https://discourse.julialang.org/t/how-to-get-linear-indices-of-array-along-a-slice-k/2922>\
**Category:** General Usage\
**Tags:** question\
**Created:** [March 28, 2017, 10:13am UTC](https://discourse.julialang.org/t/how-to-get-linear-indices-of-array-along-a-slice-k/2922 "2017-03-28T10:13:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![floswald](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/floswald/32/195_2.png) [@floswald](https://discourse.julialang.org/u/floswald)\
**Post date:** [March 28, 2017, 10:13am UTC](https://discourse.julialang.org/t/how-to-get-linear-indices-of-array-along-a-slice-k/2922/1 "2017-03-28T10:13:14Z")

</div>

Hey,  
I need to know all linear indices of an array along a certain dimension k, keeping all other dims fixed at some value. I want to know indices along that slice.

I wanted to do

```julia
A = ones(3,4,5)
# what are the linearindices at view(A,2,4,:)?
linearindices(view(A,2,4,:)) # gives me 1:5

```

so I do

```julia
id = reshape(linearindices(A),size(A))
view(id,2,4,:)
5-element SubArray{Int64,1,Base.ReshapedArray{Int64,3,Base.OneTo{Int64},Tuple{}},Tuple{Int64,Int64,Colon},true}:
 11
 23
 35
 47
 59

```

can I do better?

I guess I’m looking for `eachindex(A,2,4,:)`
