How do I plot grid points in a wedge-shaped volume?
5 ビュー (過去 30 日間)
古いコメントを表示
In the below code, how do I modify so that it gives me 3D plot of grid points? Right now I am only getting 2D plot.
yq=repmat(-10:10,100);
xq=repmat(-10:10,100)';
r=10;
teta=0:0.01:pi/6;
teta1=pi/4;
xv=[0 r*cos(teta)];
yv=[0 r*sin(teta)];
zv=0:.1:10;
[in,on] = inpolygon(xq,yq,xv,yv);
h=10^-10;
a=numel(in);
b=a*10/h;
sz=0.3;
figure (1)
plot(xv,yv) % polygon
axis equal
hold on
plot(xq(in),yq(in),'r+') % points inside
plot(xq(~in),yq(~in),'bo') % points outside
hold on
figure (2)
[X,Y,Z]=meshgrid(xv,yv,zv);
hold off
0 件のコメント
回答 (1 件)
Jonas
2022 年 11 月 29 日
you could add the third dimension like that:
x=-6:6;
[X,Y,Z]=meshgrid(x);
r=5;
phi=pi/2; % from [0,pi]
theta=pi/4; % from [0,2pi)
Xin=X<=sin(phi)*cos(theta);
Yin=Y<=sin(phi)*sin(theta);
Zin=Z<=cos(phi);
allIn=Xin & Yin & Zin & (sqrt(X.^2+Y.^2+Z.^2)<=r);
plot3(X(allIn),Y(allIn),Z(allIn),'ro','MarkerFaceColor','r')
hold on;
plot3(X(~allIn),Y(~allIn),Z(~allIn),'b.')
hold off;
xlabel('x'); ylabel('y'); zlabel('z');
view(-12.3,37.8)
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!