% MATLAB commands for problem set #1
%
% barnett 1/26/04.   NB comments (non-executable lines) start with "%"

% fill K matrix
K = [3 -2; -2 5];

% diagonalize (answer ii)
[V,D] = eig(K)
% this copies the diagonal entries into lambda vector		
lambda = diag(D)

% V =
%
%  -8.5065e-01  -5.2573e-01
%  -5.2573e-01   8.5065e-01
%
% D =
%
%   1.7639e+00            0
%            0   6.2361e+00


% frequencies
m = 1;
freq = sqrt(lambda/m);

% ratio (answer iii)
freq(2)/freq(1)

% ans =
%
%   1.8802e+00

% extract complex amplitudes: a = [a1 a2] is a vector (answer iv)
a = V' * [1; 0]     % note that [1; 0] is column vec, [1 0] is row vec

% a =
%
%  -8.5065e-01
%  -5.2573e-01

