how to get theta and phi values in degrees in 3d plot.

sir, here is my program for broadside linear antenna array. my problem is i am getting my 3d plot in radians. i want get then in degree. that T P must be in degrees please help me.please
clc;
clear all;
close all;
N=input('enter the number of elements: ');
d=input('enter inter element spacing: ');
for theta=1:360
deg2rad(theta)=theta*pi/180;
si=pi*d*cos(deg2rad(theta));
AF(theta=sin(N*si)/(N*sin(si);
end
theta=1:1:360
plot(deg2rad,AF);title('rectangular plot');
figure();
polar(deg2rad,AF);title('polar plot');
%3dplot
theta=linspace(0,2*pi,100);
phi=linspace(0,2*pi,100);
[T,P]=meshgrid(theta,phi);
PSY=2*pi*d*cos(T);
AF3=(sin((N.*PSY)/2))./(N.*(sin(PSY./2)));
[X Y Z]=sph2cart(T,P,AF3);
figure(3);
surf(X,Y,Z);
title('3d plot);
xlabel('theta'); ylabel('phi');zlabel('AF');

Answers (2)

Sireesha - can't you just initialize theta and phi in degrees instead of radians as
theta = linspace(0,360,100);
phi = linspace(0,360,100);
[T,P] = meshgrid(theta,phi);
then use sind and cosd where appropriate
PSY=2*pi*d*cosd(T);
AF3=(sind((N.*PSY)/2))./(N.*(sind(PSY./2)));

2 Comments

but sir, if we use sind then the sph2cart function cannot be justified. because during the usage of sph2cart or cart2sph it is taking radians.
I think that I misunderstood your question - you indicated that you want to convert T and P to degrees, so the above will do that. But your 3D plot is written as
surf(X,Y,Z);
where X, Y, and Z are cartesian coordinates. What does this have to do with how your 3D plot is being shown in radians? Where are you using T or P on your plot (outside of using them to obtain the cartesian coordinates)?

Sign in to comment.

instead of using surf(X,Y,Z); surf(X*180/pi,Y*180/pi,db(Z)) then we can get the plot in degrees and also the Z- co-ordinates i.e., AF in dB

Categories

Community Treasure Hunt

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

Start Hunting!