```Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: How to evenly sample hyperbola y = 1/x
Date: Thu, 9 Dec 2010 04:23:05 +0000 (UTC)
Organization: University of California San Diego
Lines: 51
Message-ID: <idplj8\$94r\$1@fred.mathworks.com>
References: <idpa5k\$4d6\$1@fred.mathworks.com> <idpcq1\$luq\$1@fred.mathworks.com>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1291868585 9371 172.30.248.37 (9 Dec 2010 04:23:05 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 9 Dec 2010 04:23:05 +0000 (UTC)
Xref: news.mathworks.com comp.soft-sys.matlab:693775

Thank you John.

I ended up implementing my own quick and dirty approach that works for the purposes that I need it for.  It's pasted below.

function EvenSamplingOfFunction(minx,delx,maxx,DS)

x   = minx:delx:maxx;
x2  = minx-delx/2:delx:maxx+delx/2; %just a shifted version
Nx  = size(x,2);
Nx2 = size(x2,2);

y   = myfun(x);
y2  = myfun(x2);

Diffy=diff(y2)/delx;

% Dy=1./x.^2; %ITS DERIVATIVE
% figure;
% hold on;
% plot(x,Dy,'k','Linewidth',5)
% plot(x,abs(Diffy),'color','r','Linewidth',5)
% pause;

S(1)    = 0;
counter = 1;
xsample(counter)=minx;

for nx=2:Nx
dS=delx*sqrt(1+Diffy(nx)^2);
S(nx)=S(nx-1)+dS;
if S(nx)>counter*DS
counter=counter+1;
xsample(counter)=x(nx);
end
end

ysample = myfun(xsample);

figure;
hold on;
plot(x,y,'k','Linewidth',5)
plot(xsample,ysample,'o','Color','r','Linewidth',5)

xsample

function F1 = myfun(xdata)
F1 = 1./xdata; %PUT ANY FUNCTION HERE
%F1 = 5*exp(-xdata); %PUT ANY FUNCTION HERE
%F1 = xdata.^2; %PUT ANY FUNCTION HERE
%F1 = 5*sin(xdata); %PUT ANY FUNCTION HERE
```