How can I paint a surface according to another scalar function?

조회 수: 3 (최근 30일)
Johnson
Johnson 2016년 1월 9일
댓글: Mike Garrity 2016년 1월 11일
Dear experts,
Assume I am given with the surface: z=4-x-y^2 . I now want every point on the surface to be colored according to a function: R(x,y,z).
Is there any simple way to make such a coloring?
Thanks a lot in advance!

채택된 답변

Mike Garrity
Mike Garrity 2016년 1월 11일
Something like this?
[x,y] = meshgrid(linspace(-2,2,50));
z = 4-x-y.^2;
c = x.^2 - y;
surf(x,y,z,c)
  댓글 수: 2
Johnson
Johnson 2016년 1월 11일
I think that yes ! Thanks a lot ! But- just to make sure, what exactly does $c$ gives? I mean, does it paint every point according to z=c ?
Mike Garrity
Mike Garrity 2016년 1월 11일
No, the 3rd argument (z) gets turned into the Z coordinate, and the 4th argument (c) gets turned into a color value. If you do this:
colorbar
You'll get a colorbar which shows the relationship between the values in c and the colors that are used for each point on the surface.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by