how to determine the trace of the graph.

4 vues (au cours des 30 derniers jours)
CHANDRABHAN Singh
CHANDRABHAN Singh le 26 Sep 2021
Réponse apportée : Nithin le 13 Oct 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?

Réponses (1)

Nithin
Nithin le 13 Oct 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.

Catégories

En savoir plus sur Line Plots dans Help Center et File Exchange

Tags

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by