# Trouble Understanding Slicing

**URL:** <https://discourse.julialang.org/t/trouble-understanding-slicing/36821>\
**Category:** New to Julia\
**Created:** [March 31, 2020, 9:30pm UTC](https://discourse.julialang.org/t/trouble-understanding-slicing/36821 "2020-03-31T21:30:29Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [April 1, 2020, 11:58am UTC](https://discourse.julialang.org/t/trouble-understanding-slicing/36821/7 "2020-04-01T11:58:13Z")

</div>

> [@kw\_martin](#):
>
> Do you know why vectors are actually needed?

I will leave the other questions aside, but I have to say that the absence of proper vectors in Matlab is a _ **huge** _ annoyance. It’s causing me _endless_ trouble almost every time I use Matlab (which is at least 5 days a week.) You really should learn to appreciate it.

The absence of vectors in Matlab means that in all code you have to make a decision and try to keep track of whether vectors are row or column vectors. Matlab pretends to be column-major, and functions like `sum`, `prod`, `max`, `plot`, etc. etc. etc. all operate along columns. But almost all built-in Matlab functions return _row-vectors_(!!!), `linspace`, `1:n`, `mynewvariable(n) = 5`, etc. etc. etc.

One of the very worst: Matlab’s `for` loops can iterate over row vectors, but not over column vectors 🤯 😡

Every time I write code I have to either check if an input is row or column, or enforce one or the other with `x(:)` or `x(:).'`, and then I suddenly have to interface with code that prefers the _opposite_ of what I have chosen (using row-vectors instead of column.)

Working in python or julia where there are proper 1-dimensional vectors is always a _huge_ relief. It’s one of the _worst_ things about Matlab.

(Yesterday, I was working with a class where most of the fields had column vectors, but _one_ of them, for some ungodly reason, was a row vector. I thought, “let me use `squeeze` in my code, so I don’t have to special-case this field, to fix this”. Didn’t work, because `squeeze` removes dimensions of length 1 – _except for row vectors_ which remain unchanged … 😫 In other words, squeezing a 1x3x4 array gives a 3x4, array, but a 1x3 array remains 1x3.)

(Postscript: Sorry about the heated post @kw_martin , but this is one of the things about Matlab that actually makes me genuinely _angry_ just thinking about it.)

---

_[View the full topic](https://discourse.julialang.org/t/trouble-understanding-slicing/36821)._
