How to make my surface plot have symmetric centre in origo?
5 views (last 30 days)
Show older comments
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 Comments
Answers (0)
See Also
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!