The log(dist) in the function causes the error message 'Matrix is singular, close to singular or badly scaled. Results may be inaccurate' How to make it work?

2 Ansichten (letzte 30 Tage)
function f = polyharm(x, y, xj, yj, fj)
p=size(x);
x = x(:);
y = y(:);
xj= xj(:);
yj= yj(:);
N = length(fj);
[Xj, X] = meshgrid(xj,xj);
[Yj, Y] = meshgrid(yj,yj);
dist = (sqrt((X-Xj).^2 + (Y-Yj).^2));
ndist = dist.^2.*log(dist);
A = [zeros(3,3) [ones(N,1) xj yj]'
ones(N,1) xj yj ndist];
abc = A\[zeros(3,1); fj];
[Xj, X] = meshgrid(xj,x);
[Yj, Y] = meshgrid(yj,y);
dist = (sqrt((X-Xj).^2 + (Y-Yj).^2));
ndist = dist.^2.*log(dist);
fc = abc(1) + abc(2)*x + abc(3)*y + ndist*abc(4:N+3);
f=reshape(fc,[p(1),p(2)]);
end

Antworten (0)

Kategorien

Mehr zu Spline Postprocessing 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