Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matlab: Easy way of getting the standard basis vectors?

It seems like this should be easy, but I'm no expert and google isn't helping.

I would like an elegant way in Matlab of producing the standard ordered basis vectors for an n-dimensional space. For example, behaviour similar to the following:

>> [e1, e2] = SOB(2);
>> e1

  e1 =    1     0

>> e2

  e2 =    0     1

I'm hoping for a 1-liner and don't really want to write a function for something so simple.

Thanks

like image 793
des4maisons Avatar asked Jan 21 '11 02:01

des4maisons


People also ask

How do you write a standard basis vector?

There are several common notations for standard-basis vectors, including {ex, ey, ez}, {e1, e2, e3}, {i, j, k}, and {x, y, z}. These vectors are sometimes written with a hat to emphasize their status as unit vectors (standard unit vectors).

How do you find the basis of a range in Matlab?

Q = orth( A ) returns an orthonormal basis for the range of A . The columns of matrix Q are vectors that span the range of A . The number of columns in Q is equal to the rank of A . Q = orth( A , tol ) also specifies a tolerance.

What is standard basis in linear transformation?

Theorem Suppose L : Rn → Rm is a linear map. Then there exists an m×n matrix A such that L(x) = Ax for all x ∈ Rn. Columns of A are vectors L(e1),L(e2),...,L(en), where e1,e2,...,en is the standard basis for Rn.


1 Answers

Why not

A = eye(N); 

then A(:,i) is your i-th basis vector

like image 65
Gunnar Avatar answered Sep 21 '22 19:09

Gunnar