how to determine the trace of the graph.

4 ビュー (過去 30 日間)
CHANDRABHAN Singh
CHANDRABHAN Singh 2021 年 9 月 26 日
回答済み: Nithin 2023 年 10 月 13 日
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?

回答 (1 件)

Nithin
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.

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

タグ

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by