Curve Fit Transient Functions using Optimization
이전 댓글 표시
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.
답변 (1개)
Alan Weiss
2018년 9월 14일
0 개 추천
댓글 수: 2
Alex R
2018년 9월 14일
Alan Weiss
2018년 9월 17일
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
카테고리
도움말 센터 및 File Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!