function [x1pos,x2pos,x1prime,x2prime]=quiverfunc(A,b,min1,max1,min2,max2)
%QUIVERFUNC:
%	quiverfunc(A,b,min1,max1,min2,max2):
%	   This function takes a contintuous, two-dimensional dynamic system
%	   of the form x' = Ax + b, where A is a matrix, x, b, and x' are two-
%	   column vectors, and produces output to give to "quiver" for vector
%	   field plotting.  Quiverfunc also takes four numbers, min1, max1,
%	   min2 and max2, to specify the length and width of the quiver plot.
%	   The arrows in quiver are automatically scaled to be the same length.
%	quiverfunc(A,b):
%	   This function is exactly the same as the above, but length and width
%	   are not specified, so there it assigns these default variables:
%	   min1 = -10, max1 = 10, min2 = -10, max2 = 10.

if nargin == 2         %if only A and b are entered
	min1 = -10;
	max1 = 10;     %default values
	min2 = -10;
	max2 = 10;
end

for var2=min2:max2              %outside for loop
	x2 = var2;
	for var1=min1:max1      %inside for loop
		x1 = var1;
		row = var1-min1+1;
		col = var2-min2+1;
		x1pos(row,col) = var1;
		x2pos(row,col) = var2;
		x1prime(row,col) = A(1)*x1 + A(3)*x2 + b(1);
		x2prime(row,col) = A(2)*x1 + A(4)*x2 + b(2);
		L = (x1prime(row,col)^2+x2prime(row,col)^2)^.5;
		screen = ((max1-min1) + (max2-min2))/2; %screen size
		eps = .001;
		if L<eps
			%do nothing
		else
		const = (screen/25)*(1/L);  %scaling constant
		x1prime(row,col) = x1prime(row,col)*const;
		x2prime(row,col) = x2prime(row,col)*const;
		end
	end
end
quiver(x1pos,x2pos,x1prime,x2prime);

		






