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 visualizaciones (últimos 30 días)
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

Respuestas (0)

Categorías

Más información sobre Spline Postprocessing en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by