Home > atmlab > geoplots > atmplot_pol2cart.m

atmplot_pol2cart

PURPOSE ^

ATMPLOT_POL2CART Plots a line given in polar coordinates.

SYNOPSIS ^

function [x,y] = atmplot_pol2cart( r, lat, varargin )

DESCRIPTION ^

 ATMPLOT_POL2CART   Plots a line given in polar coordinates.

     The given points are plotted to current axes. No hold commando is 
     applied. Plot symbol, and additional plot arguments, can be selected
     by adding arguments after *lat*. 

     Plotting is only performed if there are no output arguments. With
     output arguments, the function can be used for conversion inside
     other plotting functions.

     A scalar as input for either radius or latitude means that that value
     shall be applied for all points. If both the radii and latitudes are
     given as vectors, the both vectors must have the same size.

     Latitude 0 is placed along the horisontal (x) axis. Latitude 90 is
     in the upward vertical direction.

     To draw a heart:
        atmplot_pol2cart( linspace(0,9,91), 90:2:270, 'r-' );
        hold on
        atmplot_pol2cart( linspace(0,9,91), 90:-2:-90, 'r-' );

 FORMAT   [x,y] = atmplot_pol2cart( r, lat [, varargin ] )
        
 OUT   x          The x-coordinate for the line to draw.
       y          The y-coordinate for the line to draw.
 IN    r          A single radius or a vector of radii.
       lat        A single latitude, or a vector of latitides.
 OPT   varargin   Arguments that are passed to the *plot* commando.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

atmplot_pol2cart.m

SOURCE CODE ^

0001 % ATMPLOT_POL2CART   Plots a line given in polar coordinates.
0002 %
0003 %     The given points are plotted to current axes. No hold commando is
0004 %     applied. Plot symbol, and additional plot arguments, can be selected
0005 %     by adding arguments after *lat*.
0006 %
0007 %     Plotting is only performed if there are no output arguments. With
0008 %     output arguments, the function can be used for conversion inside
0009 %     other plotting functions.
0010 %
0011 %     A scalar as input for either radius or latitude means that that value
0012 %     shall be applied for all points. If both the radii and latitudes are
0013 %     given as vectors, the both vectors must have the same size.
0014 %
0015 %     Latitude 0 is placed along the horisontal (x) axis. Latitude 90 is
0016 %     in the upward vertical direction.
0017 %
0018 %     To draw a heart:
0019 %        atmplot_pol2cart( linspace(0,9,91), 90:2:270, 'r-' );
0020 %        hold on
0021 %        atmplot_pol2cart( linspace(0,9,91), 90:-2:-90, 'r-' );
0022 %
0023 % FORMAT   [x,y] = atmplot_pol2cart( r, lat [, varargin ] )
0024 %
0025 % OUT   x          The x-coordinate for the line to draw.
0026 %       y          The y-coordinate for the line to draw.
0027 % IN    r          A single radius or a vector of radii.
0028 %       lat        A single latitude, or a vector of latitides.
0029 % OPT   varargin   Arguments that are passed to the *plot* commando.
0030 
0031 % 2002-12-22   Created by Patrick Eriksson.
0032 
0033 
0034 function [x,y] = atmplot_pol2cart( r, lat, varargin )
0035 
0036 
0037 %= Input
0038 %
0039 rqre_nargin( 2, nargin );
0040 
0041 
0042 DEG2RAD = constants( 'DEG2RAD' );
0043 
0044 
0045 [x,y] = pol2cart( DEG2RAD * lat, r );
0046 
0047 
0048 if ~nargout
0049 
0050   plot( x, y, varargin{:} );
0051 
0052 end
0053

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005