function [calcabs calcconcs k]=pka(obsdata, phvector, kguess)
	%	applies a proton dependent speciation model and tries to tease out absorbances based on it

	[k,v,nev]=ominimize('pkares',{sort(kguess,'descend'),phvector,obsdata}); %octave version

%	attempt at hack to get around matlab
%	cfun= @(h,c) k1./(k1+h).^2-k2./(k2+h).^2;
%	rms=@(c,k) sum(sum(sqrt((ode45('cfun',h,c)*pinv(ode45('c',h,k))*obsdata-obsdata).^2)));

%	X0=[sort(kguess,'descend')]; %matlab hack
%	[dump,fval]=fminsearch(pkares(X0,phvector,obsdata),X0);% matlab hack

	disp('k') %return solution
	disp('fitted k')
	k=sort(abs(k),'descend')
	disp('pK')
	-log10(k)

%	collect solution
	h=phvector;
	k1=[k 0]'; k2=[0 k]';
	fx=@(h,c) k1./(k1+h).^2-k2./(k2+h).^2;
	tmp_k1=size(k1); %matlab hack
	
		c0=[1-k(1)/(k(1)+h(1)) k(1)/(k(1)+h(1)) zeros(1,tmp_k1(1)-2)]
	[junk,calcconcs]=ode45(fx,h,c0);
	calcabs=pinv(calcconcs)*obsdata;
end
