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!