How to plot a parametric surface with paramtric restriction

19 ビュー (過去 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 Center および File ExchangeLine Plots についてさらに検索

タグ

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by