Piecewise over circles 3d
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (2)
Walter Roberson
am 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
am 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 Kommentare
Siehe auch
Kategorien
Mehr zu Line Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!