Hello, I am expecting to see 8X8 plot of a matrix, but instead of it plots 7X7. Edge data are not plotted, why?
m = [nan, nan, nan, nan, -.053, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, -0.0167, nan, nan, nan, nan, -0.0218, nan, nan, nan, nan, nan, nan, -0.02688, nan, -0.0248, -0.0224, -0.0314, -0.0211, nan, -0.0234, -0.0437, -0.00788, -0.0235, -0.02188, -0.0219, -0.02357, -0.0233, -0.0231, nan, -0.0382, nan, -0.0215, -0.0239, nan, -0.0355, nan, nan, nan, nan, 0.0622, -0.0245, -0.0228, nan, nan, nan, nan, nan, nan, nan];
M = reshape(m, 8, 8);
for k=1:64
k = find(isnan(M))';
M(k) = 0;
end
figure (2)
surface(M) % 2D view

댓글 수: 1

Stephen23
Stephen23 2017년 4월 3일
편집: Stephen23 2017년 4월 3일
If you plot four points at the corners of a square, then you will get one square. You should count the nodes, not the squares.

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

 채택된 답변

KSSV
KSSV 2017년 4월 3일

0 개 추천

The plot is correct...in the below count the number of points:
figure (2)
surface(M) % 2D view
hold on
[X,Y] = meshgrid(1:8,1:8) ;
plot3(X,Y,M,'*r')
There are 64 points. What you are counting is number of squares.

댓글 수: 4

Roger Vota
Roger Vota 2017년 4월 3일
Thanks, it explained, but how to display matrix value as a square?
KSSV
KSSV 2017년 4월 4일
I didn't get your question..
Roger Vota
Roger Vota 2017년 4월 4일
how to plot matrix elements values as color coded squares without losing edges?
KSSV
KSSV 2017년 4월 4일
doc surf

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

질문:

2017년 4월 3일

댓글:

2017년 4월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by