taking difference of 2 surf figures of different sizes
古いコメントを表示
One is to compare two solutions and study the error by taking their difference. The two solutions are two surf figures generated by surf(x1,y1,z1) and surf(x2,y2,z2) but x1 and x2 are different in size and so are y1, y2, z1, z2. One can think of this as two solutions z1, z2 obtained on 2 meshes. Is there a smart way of taking z1-z2 and surf'ing it?
採用された回答
その他の回答 (1 件)
Walter Roberson
2025 年 1 月 10 日
N = 100;
G1 = griddedInterpolant(x1, y1, z1, 'linear', 'none');
G2 = griddedInterpolant(x2, y2, z2, 'linear', 'none');
[minx1, maxx1] = bounds(x1, 'all');
[minx2, maxx2] = bounds(x2, 'all');
minx = max(minx1, minx2);
maxx = min(maxx1, maxx2);
miny = max(miny1, miny2);
maxy = min(maxy1, maxy2);
[XQ, YQ] = ndgrid(linspace(minx, maxx,N), linspace(miny, maxy,N+1));
S1 = G1(XQ, YQ);
S2 = G2(XQ, YQ);
D12 = S1 - S2;
surf(XQ, YQ, D12, 'edgecolor', 'none');
This will only form the difference over the common x and y range. If you want the full range including the portions that do not overlap, then you need to define what you want the output to be in the areas where there is no overlap.
カテゴリ
ヘルプ センター および File Exchange で Image Arithmetic についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!