MATLAB에서 lsqlin 함수를 사용하여 선이 (x0, y0)을 통과하는 제약 조건하에 68 개의 샘플을 사용하여 데이터 집합에 직선을 맞 춥니 다. 이것에 대한 신뢰 구간을 어떻게 찾을 수 있습니까?MATLAB에서 선형 커브 피팅에 대한 신뢰 구간
내 코드 (Source)
은 또한 제약 X0 및 Y0의 값을 포함하는 매트 파일로부터 x 및 y 벡터를 포함하는 데이터 세트를 가져.
n = 1; % Degree of polynomial to fit
V(:,n+1) = ones(length(x),1,class(x)); %V=Vandermonde matrix for 'x'
for j = n:-1:1
V(:,j) = x.*V(:,j+1);
end
d = y; % 'd' is the vector of target values, 'y'.
% There are no inequality constraints in this case, i.e.,
A = [];b = [];
% We use linear equality constraints to force the curve to hit the required point. In
% this case, 'Aeq' is the Vandermoonde matrix for 'x0'
Aeq = x0.^(n:-1:0);
% and 'beq' is the value the curve should take at that point
beq = y0;
%%
[p, resnorm, residual, exitflag, output, lambda] = lsqlin(V, d, A, b, Aeq, beq);
%%
% We can then use POLYVAL to evaluate the fitted curve
yhat = polyval(p, x);