function plotim(f,varargin)
% function plotim(f,params...)
%
% plots f as an image.  f should take a matrix of row vectors of two
% variables (x and y) [thus this argument to f is nx2] and the parameters
% at the end of plotim and returns a column vector of values for each row
% of the input points.
%
% the resolution and range of the image are fixed as this function
% was designed for the RBF problem of PS3.

mins = [1 1];
maxs = [85 50];
res = 1;

X = [mins(1):res:maxs(1)]';
Y = mins(2):res:maxs(2);
nxpts = size(X,1);
nypts = size(Y,2);
X = repmat(X,1,nypts);
Y = repmat(Y,nxpts,1);
pts = [reshape(X,nxpts*nypts,1) reshape(Y,nxpts*nypts,1)];
Z = feval(f,pts,varargin{:});
Z = reshape(Z,nxpts,nypts);

image(Z);
axis equal;
colormap gray;
