# Vector column

**URL:** <https://discourse.julialang.org/t/vector-column/72925>\
**Category:** General Usage\
**Tags:** arrays, matrices\
**Created:** [December 11, 2021, 6:23am UTC](https://discourse.julialang.org/t/vector-column/72925 "2021-12-11T06:23:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![biglari](https://avatars.discourse-cdn.com/v4/letter/b/e9bcb4/32.png) [@biglari](https://discourse.julialang.org/u/biglari)\
**Post date:** [December 11, 2021, 6:23am UTC](https://discourse.julialang.org/t/vector-column/72925/1 "2021-12-11T06:23:40Z")

</div>

Hi, I have a vector that has 100 rows and two columns. I want to select the second column. Julia gives an error with the following command. Can anyone help me?  
box=[0,1,0,1]  
ninit= 100  
pdp = [LinRange(box[1],box[2],ninit),box[3].+1e-4.\*rand(ninit,1)]  
pdp\_end = ninit  
tmp = pdp[1:pdp\_end,2]

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [December 11, 2021, 6:30am UTC](https://discourse.julialang.org/t/vector-column/72925/2 "2021-12-11T06:30:25Z")

</div>

> [@biglari](#):
>
> a vector that has 100 rows and two columns

you don’t:

```julia

julia> pdp = [LinRange(box[1],box[2],ninit),box[3].+1e-4.*rand(ninit,1)]
2-element Vector{AbstractArray{Float64}}:
 range(0.0, stop=1.0, length=100)
 [6.5964924515518e-5; 4.554730444196513e-5; … ; 7.90834654968606e-5; 6.505428036713388e-5;;]

```

you have a vector of two elements, each element is `<: AbstractArray`, one of them is a Range, the other one is a `100x1` Matrix.

* * *

you probably wanted:

```julia
julia> [LinRange(box[1],box[2],ninit);; box[3].+1e-4.*rand(ninit,1)]
100×2 Matrix{Float64}:
 0.0 2.98283e-5
 0.010101 1.1944e-5
 0.020202 2.74975e-5
...
..
.

```

---

<div class="post-metadata">

**Author:** ![biglari](https://avatars.discourse-cdn.com/v4/letter/b/e9bcb4/32.png) [@biglari](https://discourse.julialang.org/u/biglari)\
**Post date:** [December 11, 2021, 6:51am UTC](https://discourse.julialang.org/t/vector-column/72925/3 "2021-12-11T06:51:46Z")

</div>

Thank you for your answer. This command gives me a vector with 200 rows and a column. I want a matrix with 100 rows and 2 columns.

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [December 11, 2021, 7:07am UTC](https://discourse.julialang.org/t/vector-column/72925/4 "2021-12-11T07:07:29Z")

</div>

Previous solution works in Julia 1.7 or later. You can simply replace the comma `,` separating the two vectors in your original `pdp` assignment, by ` ` space.

---

<div class="post-metadata">

**Author:** ![biglari](https://avatars.discourse-cdn.com/v4/letter/b/e9bcb4/32.png) [@biglari](https://discourse.julialang.org/u/biglari)\
**Post date:** [December 11, 2021, 8:08am UTC](https://discourse.julialang.org/t/vector-column/72925/5 "2021-12-11T08:08:39Z")

</div>

Thanks for your answer. My problem was solved

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [December 11, 2021, 2:12pm UTC](https://discourse.julialang.org/t/vector-column/72925/6 "2021-12-11T14:12:28Z")

</div>

2 posts were split to a new topic: [Undefined variable in loop](https://discourse.julialang.org/t/undefined-variable-in-loop/72936)
