Curve fitting while an unknown variable needs to be determined at each data point

I am trying to perform curve fitting using MATLAB wherein the fitting function f(x,a1,C1,C2,C3...) consists of a set of parameters C1,C2,C3..., the independent variable x, and another variable a1.
The problem in my case is, the variable a1 needs to be determined along with the parameters C1,C2,C3..., but unlike the parameters, a1 needs to be different at each data point. I wonder how to estimate this variable a1 at each data point while also identifying the set of parameters during curve fitting.
I know the allowable range of this variable a1. But don't know how to implement such a program.
Presently, I am using the fmincon function by defining an objective function to be minimized in the least squares sense.
Kindly assist me in finding a way to approach this problem. Thanks!

 Respuesta aceptada

Matt J
Matt J el 10 de Dic. de 2021
Editada: Matt J el 10 de Dic. de 2021
Presently, I am using the fmincon function by defining an objective function to be minimized in the least squares sense.
fmincon would work fine, but lsqcurvefit is more specifically tailored to curve fitting. The documentation and examples for lsqcurvefit should help you get started, but basically you need to supply a model function F(p,xdata) where p=[a1;C1;C2,...]
The problem in my case is, the variable a1 needs to be determined along with the parameters C1,C2,C3..., but unlike the parameters, a1 needs to be different at each data point.
That is of no consequence in terms of implementation. lsqcurvefit only cares that ydata=F(p,xdata) is a differentiable (in p) prediction of your dependent variables ydata. It does not care about the specific dependence beyond that.
However, it may be a concern that you have more parameters than data points. It might make the fit highly under-determined.

5 comentarios

Hello, thank you very much for your quick response to my question. But I was wondering if this a1 could be obtained as a column matrix. I do not need it to be a single value like other parameters. If it changes during the optimization, I think it would improve the curve fit.
Thank you.
Yes, nothing in what I posted for you assumes a1 is a scalar. You can make it a column vector if you wish.
Thank you for your clarification. I tried to search the documentation of lsqcurvefit but could not find how to define the initial estimate x0 if a1 is a column vector and other parameters C1,C2,C3..., are scalars.
The normal definition of x0 I found was as a row vector like x0 = [1,2,3,..]. But here, I have a column vector and some scalars.
Also, in this case I am not able to understand how to define the upper and lower bound of these parameters.
Torsten
Torsten el 10 de Dic. de 2021
Editada: Torsten el 10 de Dic. de 2021
Define the vector x of unknowns as x = [a1;C1;C2;C3;...] (in other words: put all your unknowns together in one single column vector x).
Thank you very much for helping me with my queries, Mr. @Matt J and Mr. @Torsten. I tried to write a program accordingly, i.e., by defining a vector of unknowns x = [a1, C1, C2,...], where a1 = [a1(1), a1(2), a1(3),...] is the array of 'a1's.
But now I now have a doubt regarding defining the fitting function.
Presently, in the function when I write x(1) to represent a1(1), it does not calculate the remaining unknowns in the a1 array.
But I need to evaluate each element of a1 for each data point of the xdata array. For e.g., a1(i) must be calculated for xdata(i). Could there be any workaround to solve this need? Kindly let me know.
Thanks for your time!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Get Started with Curve Fitting Toolbox en Centro de ayuda y File Exchange.

Productos

Versión

R2021b

Preguntada:

el 10 de Dic. de 2021

Comentada:

el 13 de Dic. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by