taking difference of 2 surf figures of different sizes
Afficher commentaires plus anciens
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?
Réponse acceptée
Plus de réponses (1)
Walter Roberson
le 10 Jan 2025
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.
1 commentaire
feynman feynman
le 10 Jan 2025
Catégories
En savoir plus sur 2-D and 3-D Plots dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!