Search code examples
matlabplotpolar-coordinatesbessel-functions

Plotting characteristics of antenna radiation in matlab


I need to plot this function enter image description here

theta = (-pi:0.01:pi);
f = 3*10^9;
c = 299792458;
da = 2;

Here's my code, but I'm not sure it's correct. I dont know where exactly dot mark should be. How to set X-Axis in degress?

beta = (2*pi*f)/c;
const= (da*beta)/2; 
j= (cos(theta)+1).*(besselj(1,const*sin(theta))./(const*sin(theta)));

My another question is how to plot this function in polar coordinates.

I made something like this.

polar(theta,j);

Is it possible to rotate that function(by y-axis) to get 3D plot?


Solution

  • Things are quite right to me, although I wouldn't use the symbol j as a variable because (as i does) it is the symbol for the imaginary unit (sqrt(-1)). Doing so you are overriding it, thus things will work until you don't need complex numbers.

    You should use element-wise operations such as (.*) when you aim at combining arrays entries element by element, as you correctly did to obtain F(\theta). In fact, cos(theta) is the array of the cosines of the angles contained in theta and so on.

    Finally, you can rotate the plot using the command Rotate 3D in the plot window. Nonetheless, you have a 2D curve (F(\theta)) therefore, you will keep on rotating a 2D graph obtaining some kind of perspective view of it, nothing more. To obtain genuine information you need an additional dependent variable (Or I misunderstood your question?). enter image description here

    EDIT: Now I see your point, you want the Surface of revolution around some axis, which I suppose by virtue of the symmetry therein to be theta=0. Well, revolution surfaces can be obtained by a bit of analytic geometry and plotted e.g. by using mesh. Check this out:

      % // 2D polar coordinate radius (your j)
      Rad= (cos(theta)+1).*(besselj(1,const*sin(theta))./(const*sin(theta)));
      Rad = abs(Rad);  % // We need its absolute value for sake of clarity
    
    
      xv = Rad .* cos(theta);  % // 2D Cartesian coordinates
      yv = Rad .* sin(theta);  % // 2D Cartesian coordinates
    
      phi = -pi:.01:pi;        % // 3D revolution angle around theta = 0
    
      % // 3D points of the surface
      xf = repmat(xv',size(phi)); 
      yf = yv' * cos(phi);
      zf = yv' * sin(phi);
    
      mesh(xf,yf,zf)
    

    enter image description here

    You can also add graphics effects

    enter image description here

    this is done via

    mesh(xf,yf,zf,'FaceColor','interp','FaceLighting','phong')
    camlight right
    

    and a finer angular discretization (1e-3).