How to plot sin(theta)*cos(phi) in spherical coordinates

조회 수: 5 (최근 30일)
Nathan Cross
Nathan Cross 2018년 2월 21일
답변: Unai San Miguel 2018년 2월 21일
[theta,phi] = meshgrid(linspace(-pi,pi,41),linspace(-pi/2,pi/2,41));
R = sin(theta)*cos(phi);
[X,Y,Z] = sph2cart(theta,phi,R);
surf(X,Y,Z)
alpha 0.5
axis vis3d
Tried using the code above but it is not giving me what I would expect (a p orbital looking shape). Any way anyone could help me figure this out?

답변 (2개)

Amjad Green
Amjad Green 2018년 2월 21일
plot3(X,Y,Z)
  댓글 수: 1
Nathan Cross
Nathan Cross 2018년 2월 21일
[theta,phi] = meshgrid(linspace(-pi,pi,41),linspace(-pi/2,pi/2,41));
R = sin(theta)*cos(phi);
[X,Y,Z] = sph2cart(theta,phi,R);
plot3(X,Y,Z)
Tried this and it seems like I am still having an issue because I am getting this for the graph

댓글을 달려면 로그인하십시오.


Unai San Miguel
Unai San Miguel 2018년 2월 21일
sin(theta) * cos(phi) is the result of the matrix multiplication of the two terms. Maybe you wanted sin(theta) .* cos(phi)? The latter has in every element of the array the product of sin(theta(i,j)) and cos(phi(i,j))

카테고리

Help CenterFile Exchange에서 Sequence and Numeric Feature Data Workflows에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by