x = r*cos(t) + ur*cos(t)
y = r*sin(t) + ur*sin(t)
z = zeros(length(x))
圆柱体长度沿z
从 0 到 10 的方向。
变量ur
随 的每个值而变化z
。它表示圆柱体的可变厚度。
我尝试plot3()
制作z
一个矩阵,但它创建了一个圆圈,而不是一个圆柱体。
x = r*cos(t) + ur*cos(t)
y = r*sin(t) + ur*sin(t)
z = zeros(length(x))
圆柱体长度沿z
从 0 到 10 的方向。
变量ur
随 的每个值而变化z
。它表示圆柱体的可变厚度。
我尝试plot3()
制作z
一个矩阵,但它创建了一个圆圈,而不是一个圆柱体。
此代码可能会有所帮助,而不是使用pol2cart
指令,您可以使用自己的方程式,结果形状取决于meshgrid
开始时指定的范围,我还添加了 Rotation 选项,当然如果您愿意,您可以评论忽略该选项。
%===========================
% Close and Clear
%===========================
clc
close all
clear all
%===========================
% making a cylinder
%===========================
[theta, r, h] = meshgrid(0:.1:6.28,0:0.1:1, 0:.2:4);
%====================================
% transforming the coordinate system
%====================================
[x, y, z] = pol2cart(theta, r, h);
%====================================================
% rotating the data points around x axis by 60 degree
%====================================================
P = (rotx(60) * [x(:), y(:), z(:)]')';
%P = [x(:), y(:), z(:)];
%=======================================
%=======================================
% Drawing The Cloud Points
%=======================================
figure('Name','Cylinder Point Cloud','NumberTitle','off');
scatter3(P(:, 1), P(:, 2), P(:, 3)); % plots a circles around sample points
title('Cylinder Point Cloud');
axis equal
%===============================================
z = 个(1,numel(x))'*(0:10)
会做的伎俩来获得使athe z从0到10的圆柱体的值。