%		VIEW ELEMENT OF MATRIX
%
%	Calls viewsym

disp('Currently defined variables:')
disp('Matrices and Transforms begin with A or T')
who

check=1;
while check
	link_num=0;
	trans_num=[0,0];
	element=[0,0];
	
	menu4=menu('View Element of Matrix',...
      'View Element of A Matrix',...
      'View Element of Transform',...
      'MAIN MENU');

	if menu4==1				%VIEW ELEMENT OF A MATRIX
		while (link_num>dhrow)|(link_num<1)
			link_num=input('Enter A matrix number (e.g., for A2 enter 2): ');
		end
		menu5=menu('View Element of A Matrix',...
         'Select Row and Column',...
         'View All Elements Sequentially',...
         'GO BACK');

		if menu5==1			%VIEW ROW AND COLUMN
			while (element>[4,4])|(element<[1,1])
				element=input('Enter Row and Column number (e.g., for A2(1,3) enter [1,3]): ');
			end
			eval(['element=viewsym(A' num2str(link_num) ',element(1),element(2))'])
		end

		if menu5==2			%VIEW SEQUENTIALLY
			disp('Elements by column. Press any key for next element')
         %format compact
			for c=1:4
				for r=1:4
					eval(['element=viewsym(A' num2str(link_num) ',r,c);'])
					eval(['disp(''A(' num2str(r) ',' num2str(c) ')='')'])
					pretty(element)
					pause
				end
			end
         %format loose
		end
	end



	if menu4==2			%VIEW ELEMENT OF TRANSFORM
      if ~fkindone
         disp('Forward Kinematics')
	   	fksym
         fkindone = 1;
      end

		menu7=menu('Which Transform',...
         'From Forward Kinematics: A13=A1*A2*A3',...
   		'From Inverse Kinematics: T23=A1^-1*T3');
		if menu7==1
			tran='A';
		else
			tran='T';
		end

		%makes sure transform number, nm, exists
		while (trans_num(1)<1)|(trans_num(1)>dhrow)|(trans_num(2)~=dhrow)
			trans_num=input('Enter Transform number (e.g., for A23=A2*A3 or T23=A^-1*T3 enter [2,3]): ');
		end

		menu6=menu('View Element of Transform',...
         'Select Row and Column',...
         'View All Elements Sequentially',...
         'GO BACK');

		if menu6==1			%VIEW ROW AND COLUMN
			while (element>[4,4])|(element<[1,1])
				element=input('Enter Row and Column number (e.g., for A13(1,3) or T13(1,3) enter [1,3]): ');
			end
			eval(['element=viewsym(' tran num2str(trans_num(1)) num2str(trans_num(2)) ',element(1),element(2))'])
		end

		if menu6==2			%VIEW SEQUENTIALLY
			disp('Elements given by columns.  Press any key to continue.')
			for c=1:4
				for r=1:4
					eval(['element=viewsym(' tran num2str(trans_num(1)) num2str(trans_num(2)) ',r,c);'])
					eval(['disp(''' tran num2str(trans_num(1)) num2str(trans_num(2)) '(' num2str(r) ',' num2str(c) ')='')'])
					pretty(element)
					pause
				end
			end
		end
	end



	if menu4==3				%MAIN MENU
		check=0;
	end
end
