How to perfom this fitting in matlab

조회 수: 2 (최근 30일)
uday
uday 2018년 7월 21일
편집: dpb 2018년 7월 21일
How to code this in matlab for least square fitting
f(i,j)= ai^2 + bj^2 + cij + di + ej + f ,
similar to this
% fitting a plane by least squares method
function rr = plane1(x,y,z)
m1 = length(x);
n1 = length(y);
a11 = n1*x'*x; a12 = sum(sum(x*y')); a13 = n1*sum(x);
a21 = a12; a22 = m1*y'*y; a23 = m1*sum(y);
a31 = a13; a32 = a23; a33 = m1*n1;
A = [a11 a12 a13;a21 a22 a23;a31 a32 a33];
for i = 1:m1
k1(i) = sum(x(i)*z(i,:));
end
b1 = sum(k1);
for j =1:n1
k2(j) = sum(y(j)*z(:,j));
end
b2 = sum(k2);
b3 = sum(sum(z));
B = [b1 b2 b3]';
coff = A\B;
a = coff(1);b = coff(2);c = coff(3);
for i = 1:m1
for j = 1:n1
z0(i,j) = a*x(i)+b*y(j)+c;
end
end
rr = z-z0;true
end

답변 (0개)

카테고리

Help CenterFile Exchange에서 Probability Distributions and Hypothesis Tests에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by