Explanation of surf plot

조회 수: 3 (최근 30일)
Louise Wilson
Louise Wilson 2023년 7월 28일
편집: Cris LaPierre 2023년 7월 28일
I used the following code to plot some example data:
A(1,1:51)=0:1:50;
A(2,2:51)=1;
A(3,2:51)=2;
A(4,2:51)=3;
A(5,2:51)=4;
A(6,2:51)=5;
A(7,2:51)=6;
A(8,2:51)=7;
A(9,2:51)=8;
A(10,2:51)=9;
A(1:10,1)=[0 1 2 3 4 5 6 7 8 9];
f=A(1,2:51);
t=A(2:10,1);
d=(A(2:end,2:end))';
surf(t,f,d,'EdgeColor','none');
view(0,90)
xlim([0 10])
colorbar
I'd like to understand how I get the code to plot all of the data.
There are nine different values in matrix 'A', but only 1-8 are plotted. Why is that?
Thanks!
  댓글 수: 3
Louise Wilson
Louise Wilson 2023년 7월 28일
Sorry, but this doesn't help me... I can see how the variables are defined, but don't understand what is wrong about it.
Louise Wilson
Louise Wilson 2023년 7월 28일
  • where x = 1, c = 1, which is what I desire - but for some reason, the final x data point (9) isn't plotted. I'd like to understand why that is, so I can remedy it.

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

채택된 답변

Cris LaPierre
Cris LaPierre 2023년 7월 28일
편집: Cris LaPierre 2023년 7월 28일
What if we simplify the code?
X = 0:9;
Y = 0:50;
A = ones(51,10) .* X;
surf(X,Y,A,'EdgeColor','none');
colorbar
surf colors the face between points. So if you have 10 point along x, there are 9 faces (0-1, 1-2, ..., 8-9).
  댓글 수: 2
Joel Hottinger
Joel Hottinger 2023년 7월 28일
I think the key here is the between the points line. This becomes very apparent if we have a 2x2 matrix:
a = [1,1;2,2];
surf(a)
view(2)
Louise Wilson
Louise Wilson 2023년 7월 28일
Yup, I see now, thanks!

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

추가 답변 (0개)

카테고리

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

태그

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by