update vectors
some typos.
This commit is contained in:
@@ -30,7 +30,7 @@ The square bracket constructor has some subtleties:
|
||||
|
||||
|
||||
* `[x,y,z]` calls `vect` and creates a 1-dimensional array
|
||||
* `[x; y; z]` calls `vcat` to **v**ertically con**cat**enate values together. With simple (scalar) values `[x,y,z]` and `[x; y; z]` are identical, but not in other cases. (For example, is `A` is a matrix then `[A, A]` is a vector of matrices, `[A; A]` is a matrix combined from the two pieces.
|
||||
* `[x; y; z]` calls `vcat` to **v**ertically con**cat**enate values together. With simple (scalar) values `[x,y,z]` and `[x; y; z]` are identical, but not in other cases. (For example, if `A` is a matrix then `[A, A]` is a vector of matrices, `[A; A]` is a matrix combined from the two pieces.
|
||||
* `[x y z]` calls `hcat` to **h**orizontally con**cat**enate values together. If `x`, `y` are numbers then `[x y]` is *not* a vector, but rather a $2$D array with a single row and two columns.
|
||||
* finally `[w x; y z]` calls `hvcat` to horizontally and vertically concatenate values together to create a container in two dimensions, like a matrix.
|
||||
|
||||
@@ -106,7 +106,7 @@ quiver([0],[0], quiver=([1],[2]))
|
||||
The cumbersome syntax is typical here. We naturally describe vectors and points using `[a,b,c]` to combine them, but the plotting functions want to plot many such at a time and expect vectors containing just the `x` values, just the `y` values, etc. The above usage looks a bit odd, as these vectors of `x` and `y` values have only one entry. Converting from the one representation to the other requires reshaping the data. We will use the `unzip` function from `CalculusWithJulia` which in turn just uses the the `invert` function of the `SplitApplyCombine` package ("return a new nested container by reversing the order of the nested container") for the bulk of its work.
|
||||
|
||||
|
||||
This function takes a vector of vectors, and returns a vector containing the `x` values, the `y` values, etc. So if `u=[1,2,3]` and `v=[4,5,6]`, then `unzip([u,v])` becomes `[[1,4],[2,5],[3,6]]`, etc. (The `zip` function in base does essentially the reverse operation, hence the name.) Notationally, `A = [u,v]` can have the third element of the first vector (`u`) accessed by `A[1][3]`, where as `unzip(A)[3][1]` will do the same. We use `unzip([u])` in the following, which for this `u` returns `([1],[2],[3])`. (Note the `[u]` to make a vector of a vector.)
|
||||
This function takes a vector of vectors, and returns a tuple containing the `x` values, the `y` values, etc. So if `u=[1,2,3]` and `v=[4,5,6]`, then `unzip([u,v])` becomes `([1,4],[2,5],[3,6])`, etc. (The `zip` function in base does essentially the reverse operation, hence the name.) Notationally, `A = [u,v]` can have the third element of the first vector (`u`) accessed by `A[1][3]`, where as `unzip(A)[3][1]` will do the same. We use `unzip([u])` in the following, which for this `u` returns `([1],[2],[3])`. (Note the `[u]` to make a vector of a vector.)
|
||||
|
||||
|
||||
With `unzip` defined, we can plot a $2$-dimensional vector `v` anchored at point `p` through `quiver(unzip([p])..., quiver=unzip([v]))`.
|
||||
|
||||
Reference in New Issue
Block a user