Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Colour of plot...not based on z coordinate, but on other variable. 1

Status
Not open for further replies.

autOverzicht

Civil/Environmental
Nov 2, 2012
5


Hi

I plotted an hyperbolic parabolid surface in Matlab. The colour of the plot is based on the z-coordinate of the surface. But, now I want to visualise the result of an other function (like: f= x+y+2) on the the surface. So the colour of the surface should be based on the result of function f and not on the z-coordinate. Can somebody explain clearly how to do this? Is it a 4dplot?...and/or how this exactly works?

Thanks in advance!

k = 1

x = linspace(-3,3);

y = linspace(-3,3);

[x,y] = meshgrid(x,y);

z = k*x.*y;

mesh(x,y,z)
 
Replies continue below

Recommended for you

I was curious about this so I looked into it & it's pretty straightforward, actually. You can add a fourth parameter to the SURF command to color the surface. In the case you've presented:
Code:
k = 1
x = linspace(-3,3,50);
y = linspace(-3,3,50);
[x,y] = meshgrid(x,y);
f= x+y+2;
z = k*x.*y;
surf(x,y,z,f);
shading flat;

Hope that helps. Here's a picture:
download.aspx

Link to picture.
Good luck!
 
great answer to a lazy question

Big clue for OP, type help <command name> at the prompt. It is amazing what you'll learn.



Cheers

Greg Locock


New here? Try reading these, they might help FAQ731-376
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor