% Copyright 1997 Thomas Mc Avoy
% MATLAB routine to select which variables are to be plotted for TE process.
% Up to 6 variables can be selected.  plt contains the number of variable to
% be plotted, titl the graph title, and pltno the number selected

function [plt,titl,pltno]=varplo1
[Glabel]=gainlbl([2 7 8]);% [2 7 8] is a dummy variable
ii=1;
pltno=1;
plt=[7;8;9;17;30;42];
[Glabel]=gainlbl([2 7 8]);
titl(1,:)=(Glabel(plt(1)+1,5:20));
titl(2,:)=(Glabel(plt(2)+1,5:20));
titl(3,:)=(Glabel(plt(3)+1,5:20));
titl(4,:)=(Glabel(plt(4)+1,5:20));
titl(5,:)=(Glabel(plt(5)+1,5:20));
titl(6,:)='G/H In Product  ';
titl=setstr(titl);
disp(' ')
disp('DEFAULT VARIABLES PLOTTED ARE: REACTOR PRESSURE, LEVEL, TEMPERATURE,')
disp('	PRODUCT FLOW, %B IN PURGE, AND G/H IN PRODUCT')
while 1
	while 1
	disp(' ')
	disp('SELECT FROM THE FOLLOWING MENU')
	disp('    1.  DISPLAY A LIST OF MEASUREMENTS THAT CAN BE PLOTTED')
	disp('    2.  SELECT A MEASUREMENT TO PLOT (UP TO 6 CAN BE SELECTED)')
	disp('    3.  FINISHED SELECTING VARIABLES')
	k=input(' ');
	if k==1|k==2|k==3
		break
	end
	end
	if k==1
		[Glabel]=gainlbl([2 7 8]);% [2 7 8] is a dummy variable 
		bl='                    ';
		MEASUREMENTS=[Glabel(2:22,1:22),[Glabel(23:42,1:20);bl]]
		s='42   G/H In Product     ';
		s1='43   A/C In Recator Feed';
		s2='44   D/E In Recator Feed';
		RATIOS=[s;s1;s2]
		disp('HIT RETURN TO CONTINUE')
		pause
	elseif k==2
		while 1
			disp('INPUT NUMBER OF MEASUREMENT TO BE PLOTTED')
			temp=input(' ');
			while (isempty(temp)==1)|temp<1|temp>44
				disp('PLEASE ENTER MEASUREMENT NUMBER AGAIN BETWEEN 1&44')
				temp=input(' ');
			end
			plt(pltno)=temp;
			if plt(pltno)<42
				titl(pltno,:)=(Glabel(plt(pltno)+1,5:20));
			elseif plt(pltno)==42
				titl(pltno,:)='G/H In Product  ';
			elseif plt(pltno)==43
				titl(pltno,:)='A/C React Feed  ';
			elseif plt(pltno)==44
				titl(pltno,:)='D/E React Feed  ';
			end
			titl=setstr(titl);
			disp(titl(pltno,:))
			pltno=pltno+1;
			break
		end
	end
	if k==3|pltno==7
		break
	end
end
if pltno==1
	pltno=7;
end
		disp(' ')
		for ii=1:pltno-1

			s=sprintf('VARIABLES TO BE PLOTTED # %3.0f',plt(ii));
			disp([s,'  ',titl(ii,:)])
		end
		disp(' ')
		pltno=pltno-1;
			if plt(ii)<42
				titl(ii,:)=(Glabel(plt(ii)+1,5:20));
			elseif plt(ii)==42
				titl(ii,:)='G/H In Product  ';
			elseif plt(ii)==43
				titl(ii,:)='A/C React Feed  ';
			elseif plt(ii)==44
				titl(ii,:)='D/E React Feed  ';
			end




