3
% direction.
I=eye(3);
Ps = AllEig(S);
% Once the eigenvalues are found, the eigenvectors are u(:,1) corresponding
% to the first eigenvalue, u(:,2) corresponding to the second, and u(:,2)
% corresponding to the second.
u([1:2],3)=Third\rhs;
% Assign the eigenvectors to Pd.
Pd=[u(:,1) u(:,2) u(:,3)];
% Normalize the eigenvectors so they are unit vectors:
Pd(:,1)=Pd(:,1)./sqrt(sum(Pd(:,1).^2));
Pd(:,2)=Pd(:,2)./sqrt(sum(Pd(:,2).^2));
Pd(:,3)=Pd(:,3)./sqrt(sum(Pd(:,3).^2));