NCCOOS Trac Projects: Top | Web | Platforms | Processing | Viz | Sprints | Sandbox | (Wind)

root/gliderproc/trunk/MATLAB/plots/rosescale.m

Revision 495 (checked in by cbc, 12 years ago)

Initial import of Stark code.

Line 
1 function [tout,rout] = rosescale(theta,x,scaleradius)
2 %ROSESCALE   Angle distribution plot.
3 %   
4 %   Same as ROSE but adds scale for radius if distribution
5 %   (or some other manipulation) is preferred over count
6 %
7 %   See also ROSE, HIST, POLAR, COMPASS.
8
9 %   Altered from orig ROSE by Catherine Edwards
10 %
11 %   Clay M. Thompson 7-9-91
12 %   Copyright 1984-2002 The MathWorks, Inc.
13 %   $Revision: 5.14 $  $Date: 2002/06/05 20:05:16 $
14
15 if isstr(theta)
16         error('Input arguments must be numeric.');
17 end
18 theta = rem(rem(theta,2*pi)+2*pi,2*pi); % Make sure 0 <= theta <= 2*pi
19 if nargin==1,
20   x = (0:19)*pi/10+pi/20;
21   scaleradius=1;
22 elseif nargin==2,
23    scaleradius=1;
24
25 elseif nargin>=2,
26   if isstr(x)
27         error('Input arguments must be numeric.');
28   end
29   if length(x)==1,
30     x = (0:x-1)*2*pi/x + pi/x;
31   else
32     x = sort(rem(x(:)',2*pi));
33   end
34 elseif nargin==3,
35   if isstr(scaleradius)
36         error('Input arguments must be numeric.');
37   end
38 end
39 if isstr(x) | isstr(theta)
40         error('Input arguments must be numeric.');
41 end
42
43 % Determine bin edges and get histogram
44 edges = sort(rem([(x(2:end)+x(1:end-1))/2 (x(end)+x(1)+2*pi)/2],2*pi));
45 edges = [edges edges(1)+2*pi];
46 nn = histc(rem(theta+2*pi-edges(1),2*pi),edges-edges(1));
47 nn(end-1) = nn(end-1)+nn(end);
48 nn(end) = [];
49
50 % Form radius values for histogram triangle
51 if min(size(nn))==1, % Vector
52   nn = nn(:);
53 end
54 [m,n] = size(nn);
55 mm = 4*m;
56 r = zeros(mm,n);
57 r(2:4:mm,:) = nn;
58 r(3:4:mm,:) = nn;
59
60 % Form theta values for histogram triangle from triangle centers (xx)
61 zz = edges;
62
63 t = zeros(mm,1);
64 t(2:4:mm) = zz(1:m);
65 t(3:4:mm) = zz(2:m+1);
66
67 if nargout<2
68   h = polar(t,r*scaleradius);
69   if nargout==1, tout = h; end
70   return
71 end
72
73 if min(size(nn))==1,
74   tout = t'; rout = r'*scaleradius;
75 else
76   tout = t; rout = r*scaleradius;
77 end
78
79
Note: See TracBrowser for help on using the browser.