function level(exprsn,val)
% level(exprsn,val) plots the level curves where the function defined by the
% string variable exprsn is equal to val.  (val may be a vector.)  For 
% dimension=1 exprsn should use the variables t and x; for dimension=2 it 
% should use the variavbles x and y.  For instance to get the circles of 
% radii 1 and 2, enter level('x^2+y^2',[1,4])

global dimension

ng=30;
ax=axis;
tg=linspace(ax(1),ax(2),ng);
xg=linspace(ax(3),ax(4),ng);
fval=zeros(ng,ng);

if dimension==1
	for i=1:ng
		t=tg(i);
		for j=1:ng
			x=xg(j);
			fval(j,i)=eval(exprsn);
		end
	end
elseif dimension==2
	for i=1:ng
		x=tg(i);
		for j=1:ng
			y=xg(j);
			fval(j,i)=eval(exprsn);
		end
    end
else
    disp('level is for dimensions 1 or 2 only.')
    return
end

if length(val)==1 
	val=val*[1,1];
end
contour(tg,xg,fval,val,'r-.');
% M. Day, June 5, 2005; May 6, 2012
