How to perfom this fitting in matlab

2 Ansichten (letzte 30 Tage)
uday
uday am 21 Jul. 2018
Bearbeitet: dpb am 21 Jul. 2018
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

Antworten (0)

Kategorien

Mehr zu Probability Distributions and Hypothesis Tests finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by