Left division with partially known coefficient

1 view (last 30 days)
I have a set of experimental data (x,y) and I have to find the unknown value of K of the equation y=0.5*x/(d*K)+x^2/(d*K)^2 where d is known. Assuming the previous equation is generalised as y= a1x+ a2x^2, I want to solve the problem with the left division [a1, a2] = C\y,but I don't know how to set the constraint that a2=f(a1), where f stands for function. How can I do it?

Accepted Answer

Torsten
Torsten on 7 Mar 2023
Edited: Torsten on 7 Mar 2023
It's a nonlinear fitting problem - backslash doesn't suffice here.
I set p = 1/(d*K) . If you like, you can retransform the result for p to get K:
K = 1/(d*p).
% Insert your own data here
p = 4.5;
xdata = linspace(0,10,100);
ydata = 0.5*p*xdata + p^2*xdata.^2 + 200*randn(size(xdata));
% Compute fitting parameter
fun = @(p,xdata) 0.5*p*xdata+p^2*xdata.^2;
F = @(p,xdata) ydata-fun(p,xdata);
p0 = 1;
p = lsqnonlin(@(p)F(p,xdata),p0)
Local minimum possible. lsqnonlin stopped because the final change in the sum of squares relative to its initial value is less than the value of the function tolerance.
p = 4.4356
% Plot solution
hold on
plot(xdata,ydata,'o')
plot(xdata,fun(p,xdata))
hold off

More Answers (1)

John D'Errico
John D'Errico on 7 Mar 2023
Edited: John D'Errico on 7 Mar 2023
If you have this relation,
y=0.5*x/(d*K)+x^2/(d*K)^2
where d is known but K unknown, then write it as:
y = (0.5/d)*(x/K) + 1/d^2*(x/K)^2
So we can think of K as an unknown scale factor, applied to x. Essentially, it stretches or compresses the curve along the x axis. But if you assume the noise is in the y-variable, then we cannot turn this directly into a simple linear least squares problem. Had the noise been known to be in the x variable, then we would have an avenue to transform this into a linear least squares problem, where we could apply backslash. We would do that by solving for (x/K), as a function of y in the quadratic polynomial. Really, you need to know where the noise lies, which variable was measured? If both variables were measured, which one would have the larger signal to noise ratio? This would suggest how best to estimate the parameter K. If you think both x AND y have some measurement noise in them, then this would become a total least squares problem, a different beast yet.
But given the model as it is, where we assume the noise lies in y as is the classic least squares formulation, the problem is nonlinear in K, so we assume a model like this:
y + noise = (0.5/d)*(x/K) + 1/d^2*(x/K)^2
where noise follows a Gaussian error structure. And that means you will need to use tools like lsqnonlin, lsqcurvefit. Or you could use fminbnd to estimate K. Or you could use fit, from the curve fitting toolbox, with a custom model as a function handle. I'd want to use your data if you needed an example of how to apply any of those tools.

Community Treasure Hunt

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

Start Hunting!