3D Plot Help Needed

7 views (last 30 days)
Matthew
Matthew on 14 Oct 2013
Commented: Walter Roberson on 14 Oct 2013
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
Walter Roberson on 14 Oct 2013
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.

Matthew
Matthew on 14 Oct 2013
Edited: Matthew on 14 Oct 2013
Walter, I did a search in help and online for trisurfinterp, but did not find it. After some reading, I tried this:
XYZ=unique(XYZ,'rows');
T=DelaunayTri(XYZ(:,1),XYZ(:,2),XYZ(:,3));
trisurf(T,XYZ(:,1),XYZ(:,2),XYZ(:,3));
However, I get the following error:
??? Error using ==> trisurf at 48
The triangulation must be composed of triangles.
I assume this means that DelaunayTri did not return useable values, but I am not sure. Any thoughts?
(Note: this shades the surface by surface height. I figured I would leave out the pressure until I could get the surface plot correct).
  5 Comments
Matthew
Matthew on 14 Oct 2013
This is frustrating:
F = TriScatteredInterp(XYZ(:,1), XYZ(:,2), XYZ(:,3), XYZ(:,3));
X = XYZ(:,1);
minX = min(X);
maxX = max(X);
Y = XYZ(:,2);
minY = min(Y);
maxY = max(Y);
Z=XYZ(:,3);
minZ=min(Z);
maxZ=max(Z);
[gridX, gridY, gridZ] = ndgrid(linspace(minX, maxX, subdiv),...
linspace(minY, maxY, subdiv),linspace(minZ, maxZ, subdiv));
gridV=F(gridX,gridY,gridZ);
surf(gridX,gridY,gridZ,gridV);
Which results in:
??? CData must be an M-by-N matrix or M-by-N-by-3 array
Error in ==> graph3d.surfaceplot.surfaceplot>localConstructor at 136
h = graph3d.surfaceplot(argin{:});
Error in ==> graph3d.surfaceplot.surfaceplot at 7
h = localConstructor(varargin{:});
Error in ==> surf at 101
hh = double(graph3d.surfaceplot(args{:},'parent',parax));
If you can tell what I am doing wrong, advice would be welcome. However, I am thinking I need to just download tecplot and be done with it.
Walter Roberson
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.

Sign in to comment.

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!