Piecewise over circles 3d
1 回表示 (過去 30 日間)
古いコメントを表示
Hey,
How would one go about doing a 3d piecewise plot over circular bases? For example:
If (x^2+y^2 <= pi^2), then z=sin(sqrt(x^2+y^2))/sqrt(x^2+y^2)
If ((x-2pi)^2+y^2 <=pi^2), then z = sin(sqrt((x-2pi)^2+y^2))/sqrt((x-2pi)^2+y^2)
If ((x+2pi)^2+y^2 <=pi^2), then z = sin(sqrt((x+2pi)^2+y^2))/sqrt((x+2pi)^2+y^2)
Else no graph there
(Then plot a 3d graph of this)
Thanks!
0 件のコメント
回答 (2 件)
Walter Roberson
2012 年 6 月 21 日
xrange = -10 : 0.01 : 10; %use appropriate range
yrange = -10 : 0.01 : 10; %use appropriate range
[x, y] = ndgrid(xrange, yrange);
z = nan(size(x));
idx = x.^2+y.^2 <= pi^2;
z(idx) = sin(sqrt(x(idx).^2+y(idx).^2))/sqrt(x(idx).^2+y(idx).^2);
idx = (x-2*pi).^2+y.^2 <=pi^2;
z(idx) = sin(sqrt((x(idx)-2*pi).^2+y(idx).^2))/sqrt((x(idx)-2*pi).^2+y(idx).^2);
idx = (x+2*pi).^2+y.^2 <=pi^2;
z(idx) = sin(sqrt((x(idx)+2*pi).^2+y(idx).^2))/sqrt((x(idx)+2*pi).^2+y(idx).^2);
surf( xrange, yrange, z)
Sean de Wolski
2012 年 6 月 21 日
[x y] = meshgrid(1:20);
z = nan(size(x)); %preallocate (account for parts that don't meet anything)
idx = (x.^2+y.^2)<=pi^2; %where meets criteria?
z(idx) = sin(sqrt(x(idx).^2+y(idx).^2))./sqrt(x(idx).^2+y(idx).^2); %fill it with stuff
and repeat the last two lines for your other two consitions
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Data Import and Network Parameters についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!