Videos
Have you tried griddata or TriScatteredInterp to create an interpolated surface?
NO! plot3 does NOT require that of Z. If all you wish is to plot a point set, then plot3 does EXACTLY what you want.
plot3(X,Y,Z,'.')
The point is, there is NO need to use meshgrid for plot3. In fact, there is no need to use meshgrid as you have tried in order to use surf. (If you will be calling griddata, then meshgrid would be necessary, but for a SMALLER mesh.)
IF you need a surface plot, then you need to create a surface. If the points are scattered, then your basic options are tools like triscatteredinter, griddata, or gridfit, the last from the file exchange.
a = [2 3 5];
b = [1 1 0];
c = a+b;
starts = zeros(3,3);
ends = [a;b;c];
quiver3(starts(:,1), starts(:,2), starts(:,3), ends(:,1), ends(:,2), ends(:,3))
axis equal
I agree with Aamir that the submission arrow.m from Erik Johnson on the MathWorks File Exchange is a very nice option. You can use it to illustrate the different methods of vector addition like so:
Tip-to-tail method:
o = [0 0 0]; %# Origin a = [2 3 5]; %# Vector 1 b = [1 1 0]; %# Vector 2 c = a+b; %# Resultant arrowStarts = [o; a; o]; %# Starting points for arrows arrowEnds = [a; c; c]; %# Ending points for arrows arrow(arrowStarts,arrowEnds); %# Plot arrowsParallelogram method:
o = [0 0 0]; %# Origin a = [2 3 5]; %# Vector 1 b = [1 1 0]; %# Vector 2 c = a+b; %# Resultant arrowStarts = [o; o; o]; %# Starting points for arrows arrowEnds = [a; b; c]; %# Ending points for arrows arrow(arrowStarts,arrowEnds); %# Plot arrows hold on; lineX = [a(1) b(1); c(1) c(1)]; %# X data for lines lineY = [a(2) b(2); c(2) c(2)]; %# Y data for lines lineZ = [a(3) b(3); c(3) c(3)]; %# Z data for lines line(lineX,lineY,lineZ,'Color','k','LineStyle',':'); %# Plot lines
As conventional methods seem to fail, I would suggest you to do it manually.
- Create a
Zmatrix full ofNaNvalues. The size of the matrix should be dependant on yourxandyvalues. - Loop over all occuring
x,y, pairs and put their (average?)zvalue in the right position of yourZmatrix. - Loop over all
NaNvalues and interpolate their value. Perhaps usingfilter2. - Use
surfto plot the resulting surface
If you have points which are described by vectors, and you want to plot them you could always use a Delauny triangulation. The function in matlab is called Tri=delauny(X,Y,Z). The data generated by this function can be shown with either trimesh(Tri,X,Y,Z) or trisurf(Tri,X,Y,Z). Keep in mind trisurf is only for 3D data. If you want to adjust the transparancy of plots in your graph use the alpha setting.
I hope this helps
