MATLAB Answers

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

8 views (last 30 days)
cgenes on 15 May 2019
Answered: cgenes on 16 May 2019
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"
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)

Accepted Answer

cgenes on 16 May 2019
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)

More Answers (0)

Community Treasure Hunt

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

Start Hunting!