Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
plot vartical surface in 3d space

Subject: plot vartical surface in 3d space

From: Reza

Date: 23 Aug, 2010 11:33:06

Message: 1 of 2

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

Subject: plot vartical surface in 3d space

From: Roger Stafford

Date: 23 Aug, 2010 16:05:22

Message: 2 of 2

"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 i-th 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

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us