Spherical coordinates to cartesian

조회 수: 8 (최근 30일)
Matteo Fè
Matteo Fè 2020년 3월 28일
댓글: Steven Lord 2020년 3월 28일
I am plotting the antenna pattern in a 3D plot where two axis are representing the theta and phi coordinates. Now I would like to change the plot in order to be able to have real 3D plot in the xyz coordiantes system,
I tried to use the sph2cart function, but I am getting weird results.
Can someone help me please?
surf(phi0rad*180/pi,theta0rad*180/pi,(abs(rho.')))
colorbar
xlabel('\phi')
ylabel('\theta')
shading interp
%%
[az, el]=meshgrid(phi0rad*180/pi, theta0rad*180/pi);
[x,y,z]=sph2cart(az,el,rho_2.');
surf(x,y,z)
I attach also a picture of what I am trying to obtain.
Thanks.

답변 (1개)

Steven Lord
Steven Lord 2020년 3월 28일
From the documentation "azimuth is the counterclockwise angle in the x-y plane measured in radians from the positive x-axis." and "elevation is the elevation angle in radians from the x-y plane."
Are your angles in radians or degrees?
  댓글 수: 2
Matteo Fè
Matteo Fè 2020년 3월 28일
Yes I was trying to follow the matlab coordinate system. The angles are in radians
Steven Lord
Steven Lord 2020년 3월 28일
From the fact that the names of the variables you're multiplying by 180/pi in your meshgrid calls imply that those variables are in radians (meaning you're gridding degree data) I don't think you calling sph2cart with angles in radians. You're trying to convert the gridded degree data.

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

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by