Home > tidal_ellipse > plot_ell.m

plot_ell

PURPOSE ^

SYNOPSIS ^

function w=plot_ell(SEMA, ECC, INC, PHA, IND)

DESCRIPTION ^

 An auxiliary function used in ap2ep and ep2ap for plotting
 tidal ellipse. The inputs, MA, ECC, INC and PHA are the output of 
 ap2ep and IND is a vector for indices for plotting a particular 
 ellipse, e.g., if IND=[2 3 1]; the ellipse corresponding to 
 the indices of (2,3,1) will be plotted.
___________________________

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function w=plot_ell(SEMA, ECC, INC, PHA, IND)
0002 %
0003 % An auxiliary function used in ap2ep and ep2ap for plotting
0004 % tidal ellipse. The inputs, MA, ECC, INC and PHA are the output of
0005 % ap2ep and IND is a vector for indices for plotting a particular
0006 % ellipse, e.g., if IND=[2 3 1]; the ellipse corresponding to
0007 % the indices of (2,3,1) will be plotted.
0008 %___________________________
0009 
0010  size_SEMA=size(SEMA);
0011  if nargin == 4;
0012      IND=1;  %by default, the first ellipse is always plotted.
0013  end
0014  
0015   len_IND=length(IND);
0016   if IND   
0017        cmd=['sub2ind(size_SEMA' ];
0018        if len_IND==1   
0019          titletxt=['Ellipse '];
0020        else
0021          titletxt=['Ellipse ('];
0022        end
0023 
0024        for k=1:len_IND;
0025           cmd=[cmd ',' num2str(IND(k))];
0026           if k<len_IND
0027              titletxt=[titletxt num2str(IND(k)) ',']; 
0028       elseif len_IND==1
0029                 titletxt=[titletxt num2str(IND(k))]; 
0030           else
0031                 titletxt=[titletxt num2str(IND(k)) ')']; 
0032           end
0033        end
0034 
0035        cmd=['n=' cmd ');'];
0036        eval(cmd);
0037 
0038        figure(gcf)
0039        clf
0040        do_the_plot(SEMA(n), ECC(n), INC(n), PHA(n));
0041        titletxt=[titletxt ',  (red) green (anti-) clockwise component'];
0042        title(titletxt);
0043    elseif len_IND
0044        msg1=['IND input contains zero element(s)!'];
0045        msg2=['No ellipse will be plotted.']; 
0046        disp(msg1);
0047        disp(msg2);
0048    end
0049 
0050 %___________________________
0051 %begin of plot subfunction
0052 function w=do_the_plot(SEMA, ECC, INC, PHA)
0053 
0054    SEMI = SEMA.*ECC;
0055    Wp = (1+ECC)/2 .*SEMA;
0056    Wm = (1-ECC)/2 .*SEMA;
0057    THETAp = INC-PHA;
0058    THETAm = INC+PHA;
0059 
0060    %convert degrees into radians
0061    THETAp = THETAp/180*pi;
0062    THETAm = THETAm/180*pi;
0063    INC = INC/180*pi;
0064    PHA = PHA/180*pi;
0065 
0066    %Calculate wp and wm.
0067    wp = Wp.*exp(i*THETAp);
0068    wm = Wm.*exp(i*THETAm);
0069    
0070    dot = pi/36;
0071    ot = [0:dot:2*pi];
0072    a = wp*exp(i*ot);
0073    b = wm*exp(-i*ot);   
0074    w = a+b;
0075 
0076    wmax = SEMA*exp(i*INC);
0077    wmin = SEMI*exp(i*(INC+pi/2));
0078 
0079    plot(real(w), imag(w))
0080    axis('equal');
0081    hold on
0082    plot([0 real(wmax)], [0 imag(wmax)], 'm');
0083    plot([0 real(wmin)], [0 imag(wmin)], 'm');
0084    xlabel('u');
0085    ylabel('v');
0086    plot(real(a), imag(a), 'r');
0087    plot(real(b), imag(b), 'g');
0088    hnd_a=line([0 real(a(1))], [0 imag(a(1))], 'color', 'r', 'marker','o');
0089    hnd_b=line([0 real(b(1))], [0 imag(b(1))], 'color', 'g', 'marker','o');
0090    hnd_w=line([0 real(w(1))], [0 imag(w(1))], 'color', 'b', 'marker','o');
0091    plot(real(a(1)), imag(a(1)), 'ro');
0092    plot(real(b(1)), imag(b(1)), 'go');
0093    plot(real(w(1)), imag(w(1)), 'bo');
0094    hnd_ab=line(real([a(1) a(1)+b(1)]), imag([a(1) a(1)+b(1)]), ... 
0095               'linestyle', '--', 'color', 'g');
0096    hnd_ba=line(real([b(1) a(1)+b(1)]), imag([b(1) a(1)+b(1)]), ... 
0097               'linestyle', '--', 'color', 'r');
0098   
0099    for n=1:length(ot);
0100          set(hnd_a, 'xdata', [0 real(a(n))], 'ydata', [0 imag(a(n))]);
0101          set(hnd_b, 'xdata', [0 real(b(n))], 'ydata', [0 imag(b(n))]);
0102          set(hnd_w, 'xdata', [0 real(w(n))], 'ydata', [0 imag(w(n))]);     
0103               hold on
0104          plot(real(a(n)), imag(a(n)), 'ro');
0105          plot(real(b(n)), imag(b(n)), 'go');
0106          plot(real(w(n)), imag(w(n)), 'bo');
0107          set(hnd_ab, 'xdata',real([a(n) a(n)+b(n)]), 'ydata', ... 
0108          imag([a(n) a(n)+b(n)]))
0109          set(hnd_ba, 'xdata',real([b(n) a(n)+b(n)]), 'ydata', ... 
0110          imag([b(n) a(n)+b(n)]))
0111    end
0112 
0113    hold off
0114 
0115 %end of plot subfunction
0116 %---------------------------
0117 %
0118 %
0119 
0120 %Authorship Copyright:
0121 %
0122 %    The author of this program retains the copyright of this program, while
0123 % you are welcome to use and distribute this program as long as you credit
0124 % the author properly and respect the program name itself. Particularly,
0125 % you are expected to retain the original author's name in this original
0126 % version of the program or any of its modified version that you might make.
0127 % You are also expected not to essentially change the name of the programs
0128 % except for adding possible extension for your own version you might create,
0129 % e.g. ap2ep_xx is acceptable.  Any suggestions are welcome and enjoying my
0130 % program(s)!
0131 %
0132 %
0133 %Author Info:
0134 %_______________________________________________________________________
0135 %  Zhigang Xu, Ph.D.
0136 %  (pronounced as Tsi Gahng Hsu)
0137 %  Research Scientist
0138 %  Coastal Circulation
0139 %  Bedford Institute of Oceanography
0140 %  1 Challenge Dr.
0141 %  P.O. Box 1006                    Phone  (902) 426-2307 (o)
0142 %  Dartmouth, Nova Scotia           Fax    (902) 426-7827
0143 %  CANADA B2Y 4A2                   email zhigangx@emerald.bio.dfo.ca
0144 %                                         zhigang_xu_98@yahoo.com
0145 %_______________________________________________________________________
0146 %
0147 %Release Date: Nov. 2000
0148

Generated on Wed 30-Nov-2005 15:40:57 by m2html © 2003