Piecewise over circles 3d
1 view (last 30 days)
Show older comments
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 Comments
Answers (2)
Walter Roberson
on 21 Jun 2012
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
on 21 Jun 2012
[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 Comments
See Also
Categories
Find more on Line Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!