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 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spline Postprocessing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!