lsqcurvefit for function with exp in numerator and denominator
Show older comments
I've played around with lsqcurvefit to have confidence in my use of it. However the one instance that it doesn't work for me is when my function contains an exponential in both the numerator and denominator. Could someone explain why this is happening and how to fix it?
Example:
Lets's say I know the function I'm looking for is f(v)=exp(3v)/(1+exp(3v))
Now I give MATLAB:
fun=@(x,xdata)=exp(x*xdata)/(1+exp(x*xdata))
xdata=[0.01;0.02;0.03;0.04;0.05]
ydata=[0.507499438;0.514995502;0.522484825;0.529964052;0.537429845]
x0=2;
I expect that by using
x = lsqcurvefit(fun,x0,xdata,ydata)
It should give me x=3. However I get the error:
Function value and YDATA sizes are incommensurate.
It works fine if the function is simply f(v)=exp(3v) though.
Accepted Answer
More Answers (0)
Categories
Find more on Get Started with Curve Fitting Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!