如何在MATLAB中使用点生成圆顶

问题描述 投票:0回答:1

我正在尝试通过使用x,y,z值生成半椭圆形的圆顶形状。在下面的代码中,我定义了x,y,z值,但无法将这些值分配给sphere。

我该如何解决?

clc    
x = [65 55.2125 50.8267 46.7398 42.9232 39.3476 35.9815 32.7882 29.7175 26.6833 23.4690 18.7605];
y = x;
z = [0.0,0.9,2.7,5.2,8.2,11.8,15.8,20.3,25.2,30.7,37.1,47.5]; % max height of dome is 47.5
[x,y,z] = sphere(20);     
x = x(12:end,:);       
y = y(12:end,:);      
z = z(12:end,:);       
r = 65;                % radius of the dome 
surf(r.*x,r.*y,r.*z); 
axis equal; 
matlab matlab-figure
1个回答
0
投票

您可以通过将NaN分配给xy的适当元素来删除球体的下半部分:

[x,y,z] = sphere(20);
I = (z<0);
x(I) = NaN;
y(I) = NaN;
surf(x,y,z)

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.