how to find x from a fixed y, when using a sigmoidal fit

HI there
sure this is super simple - but it's making my head hurt
I have a sigmoidal fit - which finds y for any x
But i want to fix y and find x (let's say y = 0.5)
and one answer does it with fsolve(), but not sure how to make it work with my sigmoidal
fsigm = @(param,xval) param(1)+(param(2)-param(1))./(1+10.^((param(3)-xval)*param(4)));
param=[0 1 5 1]; % "min", "max", "x50", "slope"
x=0:0.1:10;
y=fsigm(param,x) + 0.1*randn(size(x));
plot(x, y)
%% --------i'm sure i should use something like---------
% x = fsolve(@(x)coeffs(1)*x+coeffs(2)-y_val,0)

 Réponse acceptée

Oh yes I was being dim
of course you just rearrage the formula to solve for x
%-- rearrange the formula
syms param1 param2 param3 param4 x y
eqn = (y == param1+(param2-param1)./(1+10.^((param3-x)*param4)));
solx = solve(eqn, x)
%---- vreat function to solve for x
fsigm_for_x = @(param,y) param(3) - log(-(param(2) - y)/(param(1) - y))/(param(4)*log(10));
param=[0 1 5 1]; % "min", "max", "x50", "slope"
x = fsigm_for_x(param, 0.5)

Plus de réponses (0)

Catégories

En savoir plus sur Get Started with Curve Fitting Toolbox dans Centre d'aide et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by