% some vectors:
x=[-1:0.02:1]';  % column vector!
y=4*x/3 + 0.1*randn( size( x ) );
plot( x, y, '.b' );
axis( 'equal' );
hold on;

% new coordinate system:
% e1 = [ 3 4 ]
% e2 = [ -4 3 ]
% and normalized to unit length (factor 1/5):
e = [ 3/5 -4/5; 4/5 3/5 ];
quiver( [0 0], [0 0], e(1,:), e(2,:), 1.0, 'r' );

% project [x y] onto e1 and e2:

% % the long way:
% nx = x;
% ny = y;
% for k=1:length(x)
%     nx(k) = [x(k) y(k)]*e(:,1);
%     ny(k) = [x(k) y(k)]*e(:,2);
% end
% plot( nx, ny, '.g' );

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

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

hold off;