% some vectors:
x = [ -1:0.02:1 ];
y = x*0.5 + 0.1*randn( size(x) );
plot( x, y, '.b' );
hold on
plot( x(10), y(10), '.r' );

% new coordinate system:
%e1 = [ 3/5 4/5 ];
%e2 =  [ -4/5 3/5 ];
e1 = [ 3 4 ];
e2 =  [ -4 3 ];
me1 = sqrt( e1*e1' );
e1 = e1/me1;
me2 = sqrt( e2*e2' );
e2 = e2/me2;
quiver( 0.0, 0.0 , e1(1), e1(2), 1.0, 'r' )
quiver( 0.0, 0.0 , e2(1), e2(2), 1.0, 'g' )
axis( 'equal' )

% project [x y] onto e1 and e2:

% % the long way:
% nx = zeros( size( x ) );  % new x coordinate
% ny = zeros( size( y ) );  % new y coordinates
% for k=1:length(x)
%     xvec = [ x(k) y(k) ];
%     nx(k) = xvec * e1';
%     ny(k) = xvec * e2';
% end
% plot( nx, ny, '.g' );

% the short way:
%nx = [ x' y' ] * e1';
%nx = [x; y]' * e1';
% nx = e1 * [ x; y ];
% ny = e2 * [ x; y ];
% plot( nx, ny, '.g' );

% even shorter:
n = [e1; e2 ] * [ x; y ];
plot( n(1,:), n(2,:), '.g' );









hold off