How to plot a parametric surface with paramtric restriction

조회 수: 12 (최근 30일)
Tijs Bellefroid
Tijs Bellefroid 2022년 4월 7일
답변: Ashutosh Singh Baghel 2022년 4월 12일
I would like to plot a parametric surface in 3D, but one parameter is restricted depending on the value of the other paramter.
0 < t < 2*pi
-sqrt(2-2*sin(t)) < u < sqrt(2-2*sin(t))
param_equation = [cos(t); 1+sin(t); u]
The graph I want to get is this:

답변 (1개)

Ashutosh Singh Baghel
Ashutosh Singh Baghel 2022년 4월 12일
Hi Tijs,
I understand that you wish to plot a cylindrical surface with variable height on linear basis. To achieve this, you can try to use the 'cylinder' function from the MathWorks Documentation. To make the height of cylinder (variable 'Z') can be made variable by multiplying with a triangle matrix.
Find below an example to do so -
% Define radius of Cylinder
r = 1;
% Define number of points
N = 100;
% Get X,Y,Z coordinates
[X,Y,Z] = cylinder(r,N);
m = N/2;
u = [zeros(1,m) 1 zeros(1,m); zeros(m-1,1) flip(tril(ones(m-1))') ones(m-1,1) (triu(ones(m-1))') zeros(m-1,1)];
% Make triangle matrix
h = [u;ones(1,2*m+1);flip(u)];
% Multiply Z to vary height linearly and devide my m to scale
Z = Z*h/m;
% Plot the surface for upper half
surf(X,Y,Z);
hold on;
% Plot surface for lower half
surf(X,Y,-1*Z);
% Change view
view([32 42]);
Please find the link to create triangular matrix in 'triu' and 'tril' function from MathWorks Documentation.

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

태그

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by