The 'surf' command does not show the correct color gradient, e.g. for the 10x10 matrix below
0.0201 0.0201 0.0201 0.0201 0.0201 0.0201 0.0201 0.0201 0.0201 0.0201 0.0201
0.0149 0.0149 0.0149 0.0149 0.0149 0.0149 0.0149 0.0149 0.0149 0.0149 0.0149
0.0057 0.0057 0.0057 0.0057 0.0057 0.0057 0.0057 0.0057 0.0057 0.0057 0.0057
0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
0 0 0 0 0 0 0 0 0 0 0
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010
0.0057 0.0057 0.0057 0.0057 0.0057 0.0057 0.0057 0.0057 0.0057 0.0057 0.0057
0.0149 0.0149 0.0149 0.0149 0.0149 0.0149 0.0149 0.0149 0.0149 0.0149 0.0149
0.0201 0.0201 0.0201 0.0201 0.0201 0.0201 0.0201 0.0201 0.0201 0.0201 0.0201
it shows the figure like this
on the left and right it has same nodal values so it should show the same color gradient. Please help how to fix it.
Many Thanks in Advance.
Abdullah.

 채택된 답변

Mike Garrity
Mike Garrity 2015년 5월 19일
What's happening here is that you have FaceColor='flat'. In this case, it's using your 10x10 matrix as the Z values of the vertices. That means that it's creating a 9x9 grid of quadrilaterals. Because FaceColor='flat' wants to assign one color to each of those 81 quads, it doesn't use the last row and column of your data.
You might want to try FaceColor='interp', like this:
surf(mydata,'FaceColor','interp')
or create separate ZData and CData, like this:
myzdata = randn(10);
mycdata = randn(9);
surf(myzdata,mycdata)
Does that make sense?

댓글 수: 2

Thank you it solves the problem.
Correct. Thanks buddy

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

추가 답변 (1개)

Chad Greene
Chad Greene 2015년 5월 19일
Follow your plotting command with
shading interp

댓글 수: 2

and if you want to keep the lines of the grid,
s = surf(x);
shading interp
s.EdgeColor = 'k';
Thank you.

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

카테고리

제품

질문:

2015년 5월 19일

댓글:

2023년 11월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by