"Reza " <tabar@student.chalmers.se> wrote in message <i4tm9i$6qu$1@fred.mathworks.com>...
> Hey there,
>
> I have three vectors x,y and z which containing the positions of an object in space. I use plot3 to plot the curve in space but I want the area beneath the '2d' curve to be filled with colors which are defined in another vector "c". Meaning that instead of a line in the space, I want vertical surfaces with colors given in c. Can I do this using surf? or is there a simpler way.
>
> Cheers
       
To use 'surf' you can do the following.
m = 32; % Choose how tight the vertical mesh spacing is to be
t = linspace(0,1,m); % The vertical parameter
X = meshgrid(x,t);
Y = meshgrid(y,t);
Z = meshgrid(z,t); Z = Z.*T;
C = meshgrid(c,t);
surf(X,Y,Z,C)
There is probably a more efficient way of creating this meshgrid but this is the best I can think of at the moment. The idea is to create a mesh based on two parameters, 1) the index parameter of the vectors, x, y, z, and c, and 2) the vertical t parameter which spaces points along a vertical line between (x(i),y(i),z(i)) and (x(i),y(i),0) for each ith point.
On my system if the vertical spacing is too tight the plotted points tend to disappear so don't make m too large.
Roger Stafford
