Plotting antenna field patterns in spherical coordinates

조회 수: 63 (최근 30일)
Rhiannon
Rhiannon 2011년 7월 21일
답변: Vishwanath Iyer 2021년 6월 3일
Hi, I have a 2D array which of the form A(theta, phi) and I want to plot A as a 3D surface. I have read advice which suggests to use the sph2cart function to convert to Cartesian coordinates, then use surf or mesh, but as size(A) = 46 90, i.e. it is not a square 2D array, it will not work. Any suggestions? Thanks

채택된 답변

Kelly Kearney
Kelly Kearney 2011년 7월 21일
Why do you think your array needs to be square? Mesh, surf, etc. will accept any gridded data. Assuming your A values represent the radius at any given theta and phi:
theta = linspace(0, pi, 90);
phi = linspace(0, 2*pi, 46);
[theta, phi] = meshgrid(theta, phi);
A = ones(size(theta));
[x,y,z] = sph2cart(theta, phi, A);
mesh(x,y,z)
Is this what you're after?
  댓글 수: 1
Rhiannon
Rhiannon 2011년 7월 21일
Exactly what I was after. I was getting error messages when I was using sph2cart, and I assumed it was because I didnt have a square array, but it must have been something else.
Thank you

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

추가 답변 (2개)

Ebrahim Forati
Ebrahim Forati 2020년 6월 10일
Just added a couple of fixes to Kelley's answer:
theta = linspace(-pi/2, pi/2, 90); % theta is w.r.t. xy plane
phi = linspace(0, 2*pi, 46);
[theta, phi] = meshgrid(theta, phi);
A = ones(size(theta));
[x,y,z] = sph2cart(phi, theta, A); % fixed this line too
mesh(x,y,z)

Vishwanath Iyer
Vishwanath Iyer 2021년 6월 3일
Consider the following function in Antenna Toolbox for plotting radiation patern data:

카테고리

Help CenterFile Exchange에서 Import, Export, and Visualization에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by