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

root/gliderproc/trunk/MATLAB/seawater/sw_swvel.m

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

Initial import of Stark code.

Line 
1
2 function speed = sw_swvel(len, depth)
3
4 % SW_SWVEL    Surface wave velocity
5 %===========================================================================
6 % SW_SWVEL   $Id$
7 %           Copyright (C) CSIRO, Phil Morgan 1993.
8 %
9 % USAGE:  speed = sw_swvel(len, depth)
10 %
11 % DESCRIPTION:
12 %    Calculates surface wave velocity.
13 %
14 % INPUT:  (all must have same dimensions)
15 %   len   = wave length
16 %   depth = water depth [metres]
17 %
18 % OUTPUT:
19 %  speed   = Surface wave speed (m/s)
20 %
21 % AUTHOR:  Lindsay Pender 2005
22 %
23 % DISCLAIMER:
24 %   This software is provided "as is" without warranty of any kind.
25 %   See the file sw_copy.m for conditions of use and licence.
26 %=========================================================================
27
28 % CALLER:  general purpose
29 % CALLEE:  none
30
31 %-------------
32 % CHECK INPUTS
33 %-------------
34 [mD,nD] = size(depth);
35 [mL,nL] = size(len);
36 if mD==1 & nD==1                    % depth scalar - fill to size of len
37   depth = depth*ones(size(len));
38
39 elseif nL == nD & mD == 1           % depth is row vector
40   depth = depth(ones(1, mL), :);    % Copy down each column
41
42 elseif mL == mD & nD == 1           % depth is column vector
43   depth = depth(:, ones(1, nL));    % Copy across each row
44
45 elseif mD == mL & nD == nL
46   % Ok
47
48 else
49    error('sw_swvel.m:  Inputs arguments have wrong dimensions')
50 end %if
51
52 %-------------
53 % BEGIN
54 %-------------
55
56 g = 9.8;
57 k = 2.0 * pi ./ len;
58 speed = sqrt(g * tanh(k .* depth) ./ k);
59 return
60 %===========================================================================
61
Note: See TracBrowser for help on using the browser.