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

root/gliderproc/trunk/MATLAB/util/isint.m

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

Initial import of Stark code.

Line 
1 %
2 % ISINT determine if input matrix is integers
3 %
4 % ISINT a Matlab function to determine which input matrix positions
5 %       contain an integer or one that can be represented as an integer.
6 %       ISINT returns the integer x if x is indeed an integer,
7 %       and a 0 otherwise.
8 %
9 %       If x is a vector or matrix, ISINT returns a vector or matrix
10 %       the same size as x with each element of the input being
11 %       evaluated as above.
12 %
13 %       Ex. 1;  if x=3.2, ISINT returns 0
14 %               if x=3.0, ISINT returns 3
15 %               if x=3, ISINT returns 3
16 %
17 %       Ex. 2;  >> x=[3   3.5
18 %                     4.5 6  ];
19 %               >> isint(x)
20 %                 
21 %               ans = 3 0
22 %                     0 6
23 %
24 %
25 % Call as: >> retval=isint(x)
26 %
27 % Written by : Brian O. Blanton
28 %
29 function retval=isint(x)
30 ints=x-floor(x)==0;
31 retval=ints.*x;
32
33 %
34 %        Brian O. Blanton
35 %        Curr. in Marine Science
36 %        15-1A Venable Hall
37 %        CB# 3300
38 %        Uni. of North Carolina
39 %        Chapel Hill, NC
40 %                 27599-3300
41 %
42 %        919-962-4466
43 %        blanton@marine.unc.edu
44 %
Note: See TracBrowser for help on using the browser.