1

I have two sets of data vectors X, Y, Z and X2, Y2, Z2

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?

Brian
  • 26,662
  • 52
  • 135
  • 170

1 Answers1

2

Yes, you can plot 2 trisurfs on the same plot. Just use hold on after the first call, and hold off at the end.

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

Hope it should work if your x and y data in both sets are in the same region.

EDIT: 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?

yuk
  • 19,098
  • 13
  • 68
  • 99