function mode5(a,n,tf,S)
%function mode5(a,n,tf,S)
% Plot an entire mode shape for mode n of the system matrix A=diag(S)*a*inv(diag(S))
% and the initial condition response for that mode
% where zdot=A*z. tf is the final time of the i.c. response time history.
% If ydot=ay then z=diag(S)*y
A=diag(S)*a*inv(diag(S));
[x,p]=eig(A);
[m,w]=size(x);
clf
subplot(211)
%axis('square')
t=[-1,-1,1,1,-1];
z=[-1,1,1,-1,-1];
titlex=['Mode shape for mode ',int2str(n)]
plot(t,z)
eval(['title(''',titlex,''')'])
xlabel('real')
ylabel('imag')
hold on
plot(0,0,'o')
for i = 1:m
     y=x(i,n)
	 plot(real(y),imag(y),'*')
	 num=int2str(i);
	 eval(['text(real(y)+.05,imag(y),''',num,''')'])
 end
%axis equal
axis square
hold off
%axis('normal');

subplot(212)
xr=real(x);
t=0.:.1:tf;
c=eye(size(x));
[row,col]=size(x);
b=zeros(row,1);
d=zeros(row,1);
u=zeros(size(t));
xo=xr(:,n)
y=lsim(A,b,c,d,u,t,xo);
plot(t,y)
titlex=['initial condition response for mode ',int2str(n)];
eval(['title(''',titlex,''')']);
xlabel('time (sec)')
text2(.15,.1,'Plot order is blue, green, red, cyan, magenta, yellow, and black.')
%legend('x1', 'x2','x3','x4','x5','x6','x7')

