Appendix: Matlab Examples

It appears that
you are using AdBlocking software. The cost of running this website
is covered by advertisements. If you like it please feel free to
a small amount of
money to secure the future of this website.

It appears that
you are using AdBlocking software. The cost of running this website
is covered by advertisements. If you like it please feel free to
a small amount of
money to secure the future of this website.

In[1]:
ListPlot[{{0,0},{2,3}},PlotJoined->True]; (* Draw a line from (0,0) to (2,3) *)

In Matlab, the mean of the row-vector can be
computed as

or by using the built-in function mean().

In Matlab, if x = [x1 … xN] is a row vector, we can
compute thetotal energy as

Matlab has a function orth() which will compute an
orthonormal basis for a space given any set of vectors which span
the space.

>> help orth
ORTH Orthogonalization.
Q = orth(A) is an orthonormal basis for the range of A.
Q’*Q = I, the columns of Q span the same space as the columns
of A and the number of columns of Q is the rank of A.

See also QR, NULL.</pre>Below is an example of using <tt>orth()</tt> to orthonormalize a <a href="http://mathworld.wolfram.com/linearlyindependent.php">linearly

% While the error is not zero, it is the smallest possible
% error in the least squares sense.
% That is, yw is the optimal least-squares approximation
% to y in the space spanned by v1 and v2 (w1 and w2).
% In other words, norm(yerror) <= norm(y-yw2) for any other vector yw2 made
% using a linear combination of v1 and v2.
% In yet other words, we obtain the optimal least squares approximation
% of y (which lives in 3D) in some subspace W (a 2D subspace of 3D)
% by projecting y orthogonally onto the subspace W to get yw as above.
%
% An important property of the optimal least-squares approximation
% is that the approximation error is orthogonal to the the subspace
% in which the approximation lies. Let’s show this:
W’ * yerror % must be zero to working precision
ans =
1.0e-16 *
-0.2574
-0.0119