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 日間)
Hashan
Hashan 2017 年 9 月 11 日
編集済み: Cedric 2017 年 9 月 11 日
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 件)

カテゴリ

Help Center および File ExchangeSpline Postprocessing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by