how to determine the trace of the graph.
6 次查看(过去 30 天)
显示 更早的评论
Let's say i have plotted a cylinder in the matlab graph. Code is given below.
r = 4;
[X,Y,Z] = cylinder(r);
h = 20;
Z = Z*h;
surf(X,Y,Z);
I want to cut this cylinder with a plane (x+y+z=1) and determine the shape of the trace. I know it will be an ellipse but can we do it in matlab?
0 个评论
回答(1 个)
Nithin
2023-10-13
Hi Chandrabhan,
I understand that you want to cut the cylinder with a plane (x+y+z=1) and determine the shape of the trace.
To implement this, kindly refer to the following code snippet-
syms x y z
% Define the equation of the plane
plane_eq = x + y + z - 1;
% Solve the equation of the plane with respect to z to get the equation of the trace
trace_eq = solve(plane_eq, z);
% Plot the original cylinder
r = 4;
[X, Y, Z] = cylinder(r);
h = 20;
Z = Z * h;
surf(X, Y, Z);
hold on;
% Plot the trace on the cylinder
fimplicit3(trace_eq, [-r, r, -r, r, 0, h]);
% Plot the graph
xlabel('X');
ylabel('Y');
zlabel('Z');
title('Cylinder Cut with Plane');
legend('Cylinder', 'Trace');
hold off;
For more information regarding “fimplicit3” function, kindly refer to the following documentation:
I hope this answer helps you.
Regards,
Nithin Kumar.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!