[英]How to draw a circular 3D plot in matlab
I want to plot this function in matlab : sin(4*x)*cos(4*y)
on a disk 我想在matlab中绘制此函数:磁盘上的sin(4*x)*cos(4*y)
This is how i proceeded : 这就是我继续的方式:
syms x y;
f=@(x,y) sin(4*x)*cos(4*y);
ezmesh(f,'circ')
This method works with f=@(x,y) sin(2*x)*cos(2*y);
此方法适用于f=@(x,y) sin(2*x)*cos(2*y);
but with a more quickly varying function like f=@(x,y) sin(4*x)*cos(4*y);
但是具有更快的变化函数,例如f=@(x,y) sin(4*x)*cos(4*y);
ezmesh mistakes these variations for discontinuities. ezmesh将这些变化误认为是不连续的。 the problem is i can't use the 'circ' parameter and increase the number of points that ezmesh uses at the same time (ezmesh didn't accept it) 问题是我不能使用'circ'参数并增加ezmesh同时使用的点数(ezmesh不接受)
Is there any other way ? 还有其他办法吗?
I'm not sure if it can be done by adding another parameter. 我不确定是否可以通过添加另一个参数来完成。 However, if you want a quick-and-dirty way, here you go: 但是,如果您想要一种快速而又肮脏的方法,请执行以下操作:
x = -2*pi:0.1:2*pi;
y = -2*pi:0.1:2*pi;
[xx, yy] = meshgrid(x,y);
zz = sin(4*xx).*cos(4*yy);
zz(xx.^2 +yy.^2 >(2*pi)^2) = 0;
surf(xx,yy,zz);
Which produces: 产生:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.