How to make my surface plot have symmetric centre in origo?

조회 수: 5 (최근 30일)
Aldo
Aldo 2017년 6월 28일
편집: Aldo 2017년 6월 28일
I have a code(I think it's easier to see what I mean if you plot it):
% Convex
N = 100; % Even number of points
H = 0.02; % Height.
[x,y,z] = cylinder(-0.02:0.02,N);
x = x(:,1:ceil(N/2)+2);
x(:,end) = x(:,1);
y = y(:,1:ceil(N/2)+2);
y(:,end) = y(:,1);
y=y+(0.02+0.001); % Distance from z=0
z = -z(:,1:ceil(N/2)+2);
z(:,end) = z(:,1);
z(2,:) = -z(2,:)*H;
surf(x,z,y)
hold on
%concave
N = 100;
H = 0.02;
[x,y,z] = cylinder(-0.02:0.02,N);
x = x(:,1:ceil(N/2)+2);
x(:,end) = x(:,1);
y = y(:,1:ceil(N/2)+2);
y(:,end) = y(:,1);
y=y+(0.02+0.001);
z = z(:,1:ceil(N/2)+2);
z(:,end) = z(:,1);
z(2,:) = -z(2,:)*H;
surf(-x,-z,-y) % Difference concave/convex
axis equal
ylim([-0.04 0.04])
xlim([-0.04 0.04])
zlim([-0.04 0.04])
xlabel('x')
ylabel('y')
zlabel('z')
hold off
How can I make this centre in the middle of the y-axes, and grow in both directions if I change the height("H")?
Any tips are greatly appreciated!

답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by