3D Plot Help Needed
Show older comments
I am trying to plot a set of pressure data on to a surface which is not rectangular, but have hit a wall. I would like to end up with something similar to the images generated by Tecplot (see http://www.tecplot.com/blog/2010/08/03/taking-the-boom-out-of-supersonic-flight/ ).
My Data:
XYZ: is an m x 3 matrix of scattered x, y and z coordinates which correspond to points on the wing surface.
P: is a m x 1 vector of pressure data corresponding to each point in xyz.
I have tried to use surf(meshgrid(XYZ(:,1),XYZ(:,2),XYZ(:,1)),P) but this tries to force everything onto a square surface and looks nothing like what I want.
I thought I had done it that way in the past, but cannot locate the code which I thought had that in it and now I am second guessing myself.
Any suggestions?
Best Regards,
-Matt
Answers (2)
Walter Roberson
on 14 Oct 2013
0 votes
Have a look at trisurfinterp and its new replacement (that I do not recall the name of). You would interpolate over a grid and surf() the results of the interpolation.
5 Comments
Walter Roberson
on 14 Oct 2013
Matthew
on 14 Oct 2013
Walter Roberson
on 14 Oct 2013
You can use ndgrid() or meshgrid() to generate the arrays of target coordinates, or build them by hand. Confusingly, meshgrid() is only indirectly related to constructing surface meshes.
subdiv = 257; %arbitrary, adjust as needed
X = XYZ(:,1);
minX = min(X);
maxX = max(X);
Y = XYZ(:,2);
minY = min(Y);
maxY = max(Y);
[gridX, gridY] = ndgrid(linspace(minX, maxX, subdiv), linspace(minY, maxY, subdiv));
Then you interpolate at gridX, gridY, and then surf() or mesh() gridX, gridY, interpolatedZ
Matthew
on 14 Oct 2013
Walter Roberson
on 14 Oct 2013
The example plots you gave have two spatial dimensions (X and Y) and one value dimension (represented by color).
In the code you shouw, you are trying to plot three spatial dimensions (X, Y, Z) and one value dimension -- effectively a value for each point in a cuboid. That setup is known as having voxel information, and drawing it is "volume visualization". MATLAB does not offer any built-in volume visualization routines, but you can find one in the File Exchange.
You need to figure out how you want the "inside" values to be visible.
If your X, Y, Z coordinates are only on the surface of the original object, then you can use the AlphaData channel of a surface or patch object to make the areas "outside" the surface transparent.
You might also want to see the isosurface related commands.
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!