Curve Fit Transient Functions using Optimization
Ältere Kommentare anzeigen
I am trying to curve fit test data using optimization. I have 2 functions which characterize the data that are dependent on each other and their previous time steps, similar to what is shown below.
ydata = csvread('testdata.csv')
y1(t) = y1(t-1) + a^2 + b -( (c + y2(t-1) ) / d )
y2(t) = (b*c/a) + ( y1(t-1) - y2(t-1) ) / d )
err(t) = (y1(t) - ydata(t))^2
total_err = sum(err)
I am trying to curve fit y1 to the data by minimizing the total_err term by adjusting a, b, c, and d. Would I use fmincon or lsqcurvefit for this? If so, I cannot figure out how to apply them to these equations. Any advice is appreciated.
Antworten (1)
Alan Weiss
am 14 Sep. 2018
0 Stimmen
2 Kommentare
Alex R
am 14 Sep. 2018
Alan Weiss
am 17 Sep. 2018
You are free to write a full function, with as many conditions as you need to handle edge cases, something like
function z = myfun(x,xdata)
for I = 1:size(xdata,1)
if I = 1
% your code here
else
% more code here
end
end
Alan Weiss
MATLAB mathematical toolbox documentation
Kategorien
Mehr zu Solver Outputs and Iterative Display finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!