Assume you have a custom function, say, hill.m
, that looks like this:
function r = hill(x,xdata)
A = x(1);
k = x(2);
n =x(3);
r = A*xdata.^n;
r = r./(xdata.^n + k^n);
% when xdata is negative, return 0
r(xdata<0) = 0;
you want to find the inverse. But simply inverting the equation is messy -- and error prone as you subtract numbers that can't be negative, and take fractional powers that must be real. Imposing these conditions is dirty, and there's a better way to find the inverse numerically using fzero
Assuming the parameters of your Hill function are [10 25 2], and you want to find the point where the value of the function is 9
, this point is given by:
xinv = fzero( @(x)(hill([10 25 2],x)-9), 1)
xinv=
75.000