问题描述
我有两组数据向量X,Y,Z和X2,Y2,Z2
I have two sets of data vectors X, Y, Z and X2, Y2, Z2
我目前在不同的图形上使用trisurf绘制它们.即使X Y和X2 Y2不同,我也可以将它们绘制在同一张图上吗?我可以减去表面图吗?
I currently plot them using trisurf on different graphs. Can I plot them on the same graph even if X Y and X2 Y2 are different. Can I subtract the surface plots?
推荐答案
是的,您可以在同一图上绘制2个trisurf.只需在第一次调用后使用hold on
,然后在最后使用hold off
.
Yes, you can plot 2 trisurfs on the same plot. Just use hold on
after the first call, and hold off
at the end.
要从另一个中减去一个trisurf图,我想您需要将一组X/Y坐标内插到另一组.为此,请尝试使用 INTERP2 :
To substract one trisurf plot from another I think you need to interpolate one set of X/Y coordinates to another. Try to use INTERP2 for this:
Z2i = interp2(X2,Y2,Z2,X,Y);
tri = delaunay(X,Y);
trisurf(tri,X,Y,Z) % first plot
hold on
trisurf(tri,X2,Y2,Z2) % second plot
trisurf(tri,X,Y,Z2-Z2i) % difference
hold off
希望两组中的x和y数据都位于同一区域.
Hope it should work if your x and y data in both sets are in the same region.
编辑:将INTERP2用于meshgrid生成的X和Y.有关向量以及如何使用TriScatteredInterp的信息,请参见其他SO问题:如何从等值线生成3-D曲面?
Use INTERP2 for X and Y generated by meshgrid. For vectors and how to use TriScatteredInterp see other SO question: How Do I Generate a 3-D Surface From Isolines?
这篇关于彼此相减两个trisurf地块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!