How to plot a parametric surface with paramtric restriction
4 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
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]);
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Surface and Mesh Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!