MATLAB: How to fit inverse proportional function

curve fittinginverse proportional function

x,y is a vectors. How to get a fitting function like y'=a/(x+b)+c

Best Answer

Your function could be difficult to fit. You can use the fminsearch function to estimate the parameters:
% Define ‘x’ and ‘y’ here
% Parameter Vector: b(1) = a, b(2) = b, b(3) = c
yfit = @(b,x) b(1)./(x + b(2)) + b(3); % Objective Function
CF = @(b) sum((y-yfit(b,x)).^2); % Cost Function
b0 = rand(1,3)*10; % Initial Parameter Estimates
[B, fv] = fminsearch(CF, b0); % Estimate Parameters
Note that ‘x’ and ‘y’ have to be defined in your workspace