how to determine the trace of the graph.

4 visualizaciones (últimos 30 días)
CHANDRABHAN Singh
CHANDRABHAN Singh el 26 de Sept. de 2021
Respondida: Nithin el 13 de Oct. de 2023
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?

Respuestas (1)

Nithin
Nithin el 13 de Oct. de 2023
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.

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by