| 4 | 1/1 | 返回列表 |
| 查看: 945 | 回復: 3 | ||
雨人007銀蟲 (小有名氣)
|
[求助]
MATLAB 中有關griddata的計算原理,看不懂,求詳解!
|
|
>>type griddata function [xi,yi,zi] = gdatav4(x,y,z,xi,yi) %GDATAV4 MATLAB 4 GRIDDATA interpolation % Reference: David T. Sandwell, Biharmonic spline % interpolation of GEOS-3 and SEASAT altimeter % data, Geophysical Research Letters, 2, 139-142, % 1987. Describes interpolation using value or % gradient of value in any dimension. xy = x( + y( *sqrt(-1);% Determine distances between points d = xy(:,ones(1,length(xy))); d = abs(d - d.'); n = size(d,1); % Replace zeros along diagonal with ones (so these don't show up in the % find below or in the Green's function calculation). d(1:n+1:numel(d)) = ones(1,n); non = find(d == 0, 1); if ~isempty(non), % If we've made it to here, then some points aren't distinct. Remove % the non-distinct points by averaging. [r,c] = find(d == 0); k = find(r < c); r = r(k); c = c(k); % Extract unique (row,col) pairs v = (z(r) + z(c))/2; % Average non-distinct pairs rep = find(diff(c)==0); if ~isempty(rep), % More than two points need to be averaged. runs = find(diff(diff(c)==0)==1)+1; for i=1:length(runs), k = (c==c(runs(i))); % All the points in a run v(runs(i)) = mean(z([r(k);c(runs(i))])); % Average (again) end end z(r) = v; if ~isempty(rep), z(r(runs)) = v(runs); % Make sure average is in the dataset end % Now remove the extra points. z(c) = []; xy(c, = [];xy(:,c) = []; d(c, = [];d(:,c) = []; % Determine the non distinct points ndp = sort([r;c]); ndp(ndp(1:length(ndp)-1)==ndp(2:length(ndp))) = []; warning('MATLAB:griddata:NonDistinctPoints',['Averaged %d non-distinct ' ... 'points.\n Indices are: %s.'],length(ndp),num2str(ndp')) end % Determine weights for interpolation g = (d.^2) .* (log(d)-1); % Green's function. % Fixup value of Green's function along diagonal g(1:size(d,1)+1:numel(d)) = zeros(size(d,1),1); weights = g \ z( ;[m,n] = size(xi); zi = zeros(size(xi)); jay = sqrt(-1); xy = xy.'; % Evaluate at requested points (xi,yi). Loop to save memory. for i=1:m for j=1:n d = abs(xi(i,j)+jay*yi(i,j) - xy); mask = find(d == 0); if ~isempty(mask), d(mask) = ones(length(mask),1); end g = (d.^2) .* (log(d)-1); % Green's function. % Value of Green's function at zero if ~isempty(mask), g(mask) = zeros(length(mask),1); end zi(i,j) = g * weights; end end if nargout<=1, xi = zi; end |

捐助貴賓 (著名寫手)
銀蟲 (小有名氣)

捐助貴賓 (著名寫手)
| 4 | 1/1 | 返回列表 |
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 321求調劑 +8 | 何潤采123 2026-03-18 | 10/500 |
|
|---|---|---|---|---|
|
[考研] 材料與化工求調劑 +7 | 為學666 2026-03-16 | 7/350 |
|
|
[考研] 085600材料與化工調劑 324分 +10 | llllkkkhh 2026-03-18 | 12/600 |
|
|
[考研] 324分 085600材料化工求調劑 +3 | llllkkkhh 2026-03-18 | 3/150 |
|
|
[考研] 346求調劑[0856] +3 | WayneLim327 2026-03-16 | 6/300 |
|
|
[考研] 311求調劑 +11 | 冬十三 2026-03-15 | 12/600 |
|
|
[考研] 一志愿西南交大,求調劑 +4 | 材化逐夢人 2026-03-18 | 4/200 |
|
|
[考研] 收復試調劑生 +4 | 雨后秋荷 2026-03-18 | 4/200 |
|
|
[考研] 302求調劑 +10 | 呼呼呼。。。。 2026-03-17 | 10/500 |
|
|
[考研] 生物學071000 329分求調劑 +3 | 我愛生物生物愛?/a> 2026-03-17 | 3/150 |
|
|
[考研] 275求調劑 +4 | 太陽花天天開心 2026-03-16 | 4/200 |
|
|
[考研] 一志愿,福州大學材料專碩339分求調劑 +3 | 木子momo青爭 2026-03-15 | 3/150 |
|
|
[考研] 274求調劑 +5 | 時間點 2026-03-13 | 5/250 |
|
|
[考研] 304求調劑 +5 | 素年祭語 2026-03-15 | 5/250 |
|
|
[考研] 304求調劑 +4 | ahbd 2026-03-14 | 4/200 |
|
|
[考研] 0703一志愿211 285分求調劑 +5 | ly3471z 2026-03-13 | 5/250 |
|
|
[考研] 中科院材料273求調劑 +4 | yzydy 2026-03-15 | 4/200 |
|
|
[考研] 26考研一志愿中國石油大學(華東)305分求調劑 +3 | 嘉年新程 2026-03-15 | 3/150 |
|
|
[考研] 22408總分284求調劑 +3 | InAspic 2026-03-13 | 3/150 |
|
|
[考研] 266求調劑 +4 | 學員97LZgn 2026-03-13 | 4/200 |
|