# Slicing vector into matrix

**URL:** <https://discourse.julialang.org/t/slicing-vector-into-matrix/115844>\
**Category:** New to Julia\
**Tags:** question, vector\
**Created:** [June 19, 2024, 9:10am UTC](https://discourse.julialang.org/t/slicing-vector-into-matrix/115844 "2024-06-19T09:10:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sahil\_Khan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sahil_khan/32/47573_2.png) [@Sahil\_Khan](https://discourse.julialang.org/u/Sahil_Khan)\
**Post date:** [June 19, 2024, 9:10am UTC](https://discourse.julialang.org/t/slicing-vector-into-matrix/115844/1 "2024-06-19T09:10:40Z")

</div>

How to do this ? If there is a function?

I have a large vector with repeating numbers after some interval. I want to slice it just like how showed in second output.

Thank you 🙂

```julia

julia> a = [1, 1, 1, 1, 2, 2, 2, 2]
12-element Vector{Int64}:
 1
 1
 1
 1
 2
 2
 2
 2

```

```julia
4×2 Matrix{Int64}:
 1 2
 1 2
 1 2
 1 2

```

---

<div class="post-metadata">

**Author:** ![kellertuer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kellertuer/32/220707_2.png) [@kellertuer](https://discourse.julialang.org/u/kellertuer)\
**Post date:** [June 19, 2024, 9:19am UTC](https://discourse.julialang.org/t/slicing-vector-into-matrix/115844/2 "2024-06-19T09:19:15Z")

</div>

[https://docs.julialang.org/en/v1/base/arrays/#Base.reshape](https://docs.julialang.org/en/v1/base/arrays/#Base.reshape)
