How to plot a parametric surface with paramtric restriction

1 view (last 30 days)
Tijs Bellefroid
Tijs Bellefroid on 7 Apr 2022
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:

Answers (1)

Ashutosh Singh Baghel
Ashutosh Singh Baghel on 12 Apr 2022
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
hold on;
% Plot surface for lower half
% Change view
view([32 42]);
Please find the link to create triangular matrix in 'triu' and 'tril' function from MathWorks Documentation.





Community Treasure Hunt

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

Start Hunting!

Translated by