function C = set(C,F,V)
% SET Set some attributes of a SDMaxEnt classifier object  
%
% C = SET(C,F,V) where F is the attribute and V is value. Supported
% field/value pairs: 
%
%  'params':  A struct with field/entries of the proper size
    
% SDMAXENT.SET

      
% Jerod Weinman
% jerod@acm.org
% (c) 2008

% $Id: set.m 1 2009-05-07 13:41:00Z weinman $
 
% Jerod Weinman
% jerod@acm.org
% Copyright 2007, 2008, 2011
 
%    This file is part of Matlab SDMaxEnt.
%
%    Matlab SDMaxEnt is free software: you can redistribute it and/or modify
%    it under the terms of the GNU General Public License as published by
%    the Free Software Foundation, either version 3 of the License, or
%    (at your option) any later version.
%
%    Matlab SDMaxEnt is distributed in the hope that it will be useful,
%    but WITHOUT ANY WARRANTY; without even the implied warranty of
%    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%    GNU General Public License for more details.
%
%    You should have received a copy of the GNU General Public License
%    along with Matlab SDMaxEnt.  If not, see <http://www.gnu.org/licenses/>.
  
  switch F
	
   case 'params'
	if ~isa(V,'struct')
	  error('params must be a struct')
	else
	  for f=fieldnames(C.params)'
		if ~isfield(V,f{:})
		  error(sprintf('params struct requires field %s',f{:}));
		else
		  szV = size(V.(f{:}));
		  szP = size(C.params.(f{:}));
		  
		  if length(szV)~=length(szP) || any( szV ~= szP)
			error(sprintf('size mismatch for params field %s',f{:}));
		  else
			C.params.(f{:}) = V.(f{:});
		  end;
		end;
	  end;
	end;
   
   otherwise
	error(sprintf('unknown field %s',F));
  
  end;
  
