"Matrix" is the Latin word for womb. The origin of mathematical matrices has a long history. The term "matrix" in combinatorics was introduced in 1850 by the British mathematician James Joseph Sylvester (1814--1897), who also coined many mathematical terms or used them in "new or unusual ways" mathematically, such as graphs, discriminants, annihilators, canonical forms, minor, nullity, and many others.
Access an element of matrix A
using a single index: indices count down the first column, then down the
second column, etc.
Build an m×n matrix of zeros
matrix(0,nrow=m,ncol=n)
# or just
matrix(0,m,n)
Build an n × n identity matrix
Build a diagonal n × n matrix A using elements of
vector v as diagonal entries
Extract diagonal elements of
matrix A
“Glue” two matrices A1 and A2
(with the same number of rows) side-by-side
“Stack” two matrices A1 and A2
(with the same number of
columns) on top of each other
Extract column 2 of matrix A
A[,2]
that gives the result as a vector. To make the result a m×1 matrix
(which is a column-vector) instead, do
A[,2,drop=FALSE]
Extract second row of matrixA
A[2,]
that gives the result as a vector. To make the result a m×1 matrix
(which is a column-vector) instead, do
A[2,,drop=FALSE]
Example:
The paraboloid example shows that any function with three variables can be visually represented using the plot and plotly functions.
Next, we utilize anothe rpackage plotly for creating interactive web-based graphs via the open source JavaScript:
Rgl is another package that is useful for 3d plotting. It is interactive;
however, mac users must download XQuartz to use the rgl package: https://www.xquartz.org
■
Example:
We plot a torus with the follwoing commands: