To compute the inner product of two vectors x and y in R^n, we can use the dot product function in MATLAB:
main.m128 chars3 lines
The dot function in MATLAB takes two vectors as inputs and returns their dot product, which is equivalent to the inner product.
Note that both x and y must be column vectors of the same dimension n. If the vectors are row vectors, we can take their transpose to get column vectors:
main.m112 chars3 lines
Here, the ' operator is used to take the transpose of x, and the * operator is used for matrix multiplication.
gistlibby LogSnag