How to plot a parametric surface with paramtric restriction
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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:
0 Kommentare
Antworten (1)
Ashutosh Singh Baghel
am 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
surf(X,Y,Z);
hold on;
% Plot surface for lower half
surf(X,Y,-1*Z);
% Change view
view([32 42]);
0 Kommentare
Siehe auch
Kategorien
Mehr zu Surface and Mesh Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!