
plotting 3D surface grids
조회 수: 11 (최근 30일)
이전 댓글 표시
what specification should i use in order to get this sort (colour) of surf (X, Y, Z) grid attached below?

댓글 수: 0
채택된 답변
Star Strider
2016년 7월 30일
This will reproduce it:
x = -40:5:40;
y = ones(1,16);
[X,Y] = meshgrid(x,y);
z = @(x,y) bsxfun(@plus, tanh(x * 0.1).*0.1, 1.5*Y);
Z = z(X,Y);
figure(1)
mesh(Z)
grid on
qx = xlim;
axis([1 17 1 16 1.4 max(zlim)])
view([25 60])
xt = 1:4:length(x);
xtl = regexp(sprintf('%.0f ',linspace(-40, 40, length(xt))), ' ', 'split');
set(gca, 'XTick',xt, 'XTickLabel',xtl(1:end-1))
yt = 1:5:length(y);
ytl = regexp(sprintf('%.0f ',linspace(0, 4, length(yt))), ' ', 'split');
set(gca, 'YTick',yt, 'YTickLabel',ytl(1:end-1))
zt = linspace(1.40, 1.60, 5);
ztl = regexp(sprintf('%.2f ',zt), ' ', 'split');
set(gca, 'ZTick',zt, 'ZTickLabel',ztl(1:end-1))
yielding this plot:

Reproducing it exactly without knowing the code that created the original means that this code is not as efficient as I would like it to be. Nevertheless, it works.
댓글 수: 2
Star Strider
2016년 7월 30일
For the axis scales to display correctly, use both mesh independent coordinates arguments in the mesh call:
mesh(X,T,Z)
That should do what you want.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!