필터 지우기
필터 지우기

How to minimize residual error (i.e., cost function) using least squares?

조회 수: 5 (최근 30일)
TJ
TJ 2019년 12월 27일
편집: TJ 2020년 1월 4일
I have a data set, 'x' and 'xhat', where 'x' is the experimental data and 'xhat' is calculated. The cost functions are b1, b2 and b3 - these are the values that need to be minimized to reduce the residual error. M is previously calculated elsewhere in the script.
% x is the experimental data
T = 100 + b1
K = b2 + b3 * M^2
xhat = T + (T * K * M^2) % xhat is supposed to be calculated
res=x-xhat % residual error
min(b1,b2,b3)= sum(||res||).^2 % Least squares - Levenberg-Marquardt Algorithm
Having never worked with cftool before, can someone assist me in finding the values of the cost function?
Thanks in advance!

답변 (1개)

Shubh Sahu
Shubh Sahu 2019년 12월 31일
Load your dataset in workspace and then open cftool. Select data to fit in curve. Select the model type 'custom' and input the whole equation which you want to minimize. Please refer to these links for further help :
  댓글 수: 1
TJ
TJ 2020년 1월 4일
편집: TJ 2020년 1월 4일
Shubh,
Thank you for the links. I was only able to implement a two variable custom equation - in my case, x = the equation behind
x = the equation behind '100' in T = 100 + b1
y = the value of M
However, I believe I'll need a three independent variable custom equation to calculate the residuals. How do I implement a three independent variable custom equation?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by