Given Dataset, find Optimal Parameters of a Definite Integral Function

1 Ansicht (letzte 30 Tage)
EC
EC am 28 Mär. 2022
Beantwortet: Vatsal am 26 Dez. 2023
Suppose I know the relationship between y and x to be:
which does not have a closed form solution.
x0 and m are known and positive real numbers. a, b and c are parameters which I want to obtain for a given dataset, which contains N data points: (x1,y1), (x2,y2),...(xi,yi)...(xN,yN).
How can I implement a code in MATLAB to find the optimal values of a, b and c to minimize the sum of square errors?
I've tried the following code, where xIn and yIn are vectors consisting the data points and D = [a b c]'. MATLAB returns an error that for the integral function, the upper bound has to be a scalar.
fun = @(D)integral(@(x)(D(1)*x.^2 + D(2)*x + D(3)).^-m,x0,xIn) - yIn;
D0 = [1 1 1];
D = lsqnonlin(fun,a0);
Any help will be greatly appreciated.

Antworten (1)

Vatsal
Vatsal am 26 Dez. 2023
Hi,
I understand that you want to find Optimal Parameters of a Definite Integral Function. The issue you are encountering is because MATLAB’s "integral" function expects the upper and lower bounds of the "integral" to be scalars, not vectors. However, in the provided code “xIn” is passed as upper bound, which is a vector. To resolve this, the code should be modified to process each data point separately, accumulating the squared errors from all points. This involves iterating through each data point, evaluating the integral with the specific “x” value as the upper bound, and then calculating the squared error.
Below is the modified code to accomplish this:
fun = @(D) sum(arrayfun(@(x, y) (integral(@(t)(D(1)*t.^2 + D(2)*t + D(3)).^-m, x0, x) - y)^2, xIn, yIn));
D0 = [1 1 1];
D = lsqnonlin(fun, D0);
I hope this helps!

Kategorien

Mehr zu Get Started with Optimization Toolbox finden Sie in Help Center und File Exchange

Produkte


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by