I would like to plot a surface in matlab; however, matlab is assigning each element of the matrix to an intersection of the meshgrid. I want each element of my matrix to be the value of each square in the meshgrid, not at the intersections. The result of this problem is that I am 'missing' a row/column on one end of my surface plot due to the color mapping. Using the data cursor I can confirm that the values are there, except on the intersections of the grid lines; hence the edges are effectively missing a row/column visually. I want a 3D equivalent of imagesc. Any ideas?

댓글 수: 7

Massimo Zanetti
Massimo Zanetti 2016년 9월 28일
A square has 4 vertex.. So you cannot assign one value to a square.
Cankut Eker
Cankut Eker 2016년 9월 28일
So there is no way to center the values onto the squares? Is there a way to shift the meshgrid so that it seems like the intersections are in the middle of the squares?
KSSV
KSSV 2016년 9월 28일
How about assigning all four values same to each vertex?
Cankut Eker
Cankut Eker 2016년 9월 28일
That's a good idea, but I think there may be a discontinuity in some row or column at the end since there will inevitably be 2 corners=x and the other 2 corners=y.
KSSV
KSSV 2016년 9월 28일
Have you tried shading interp after plotting the surface?
Cankut Eker
Cankut Eker 2016년 9월 28일
Thank you so much! It worked! Is there anyway to put the surface lines on?
Cankut Eker
Cankut Eker 2016년 9월 28일
Nevermind figured it out. Thank you very much everyone!

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

 채택된 답변

José-Luis
José-Luis 2016년 9월 28일

0 개 추천

You could use image() instead.

댓글 수: 4

Cankut Eker
Cankut Eker 2016년 9월 28일
Image does work to fix this problem, but it still only generates a 2D plot, unless i'm missing something. Thanks for the suggestion though!
José-Luis
José-Luis 2016년 9월 28일
In that case I think you need to interpolate first and then use surf() and variants.
Cankut Eker
Cankut Eker 2016년 9월 28일
I think this would have also solved it so I am going accept this as an answer, including the line 'shading interp' solved it. I just need to find a way to put the lines back into the surface plot :)
Cankut Eker
Cankut Eker 2016년 9월 28일
The property 'edgecolor','k' did the trick ;)

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

추가 답변 (0개)

카테고리

제품

질문:

2016년 9월 28일

댓글:

2016년 9월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by