function rhovec = plot_growth_factor(lb,ub,matname,fignum)
% rhovec = plot_growth_factor(lb,ub,matname)
% Task : Plots the growth factor rho for the family
%		 of matrices available through the Matlab
%		 gallery by typing 
%				>> gallery(matname,n)
%		 where n is the size of the matrix. 
%		 If matname = 'randn' or the third parameter
%		 is not provided, instead of the Matlab
%		 gallery the growth factor is plotted for random
%		 matrices (i.e. the matrices are generated by
%		 randn(n);). The growth factor is plotted for 
%		 matrices of various sizes ranging in [lb,ub].
%		 rhovec at termination is the vector of
%		 growth factors.


if nargin < 3
	matname = 'randn';
end

if nargin < 4
	fignum = 1;
end


jvec = [];
rhovec = [];

for j = lb:ub
	if (length(matname) == 5) & (min(matname == 'randn') > 0)
		A =randn(j);
	else
		A = gallery(matname,j);
	end
	rhovec = [rhovec growth_factor(A)];
	jvec = [jvec j] ;
end

figure(fignum);
plot(jvec,rhovec,'b-');
				
return;