Fit to find the value of an unknown parameter

조회 수: 5 (최근 30일)
Tomer
Tomer 2020년 3월 24일
댓글: Tomer 2020년 3월 25일
Hi. I want to determine the value of a paramter (H) using a fit to measurements. I am assuming a list of H values.
A=0.1;
B=0.5;
C=100;
x; % x - coordinates
P1; % Measured data
H=0.0001:0.00005:0.05; % Assuming some values of H
for i=1:length(H)
i
P2=H(i)*(((1/A)*log(x.*H(i)/C))+B); % Estimation
R2(i)=rsquared(P1,P2) % Calculating the R2 value using rsquared function
end
I want the same number of P2 estimations as the number of assumed H values. I don't get it here. I want to save the values of R2 and select the value of H which gives R2=0.95.

채택된 답변

Stephan
Stephan 2020년 3월 24일
Try to optimize with least squares:
A=0.1;
B=0.5;
C=100;
% Range for H
lb = 0.0001;
ub = 0.05;
best_H = fminbnd(@(H)sseval(H,x,P1,A,B,C),lb,ub)
P2 = best_H*(((1/A)*log(x.*best_H/C))+B)
function sse = sseval(H,x,P1,A,B,C)
sse=sum((H*(((1/A)*log(x.*H/C))+B)-P1).^2);
end
see also:
  댓글 수: 3
Stephan
Stephan 2020년 3월 24일
Can you attach the data?
Tomer
Tomer 2020년 3월 25일
Its solved now. Thanks.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Least Squares에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by