how to get theta and phi values in degrees in 3d plot.
Afficher commentaires plus anciens
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');
Réponses (2)
Geoff Hayes
le 19 Fév 2015
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 commentaires
sireesha dammalapati
le 19 Fév 2015
Geoff Hayes
le 21 Fév 2015
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)?
sireesha dammalapati
le 9 Mar 2015
0 votes
Catégories
En savoir plus sur Surface and Mesh Plots dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!