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

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

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

Initial import of Stark code.

Line 
1 function l=isodd(v)
2 % function l=isodd(v)
3 %
4 % is the argument even, odd or else
5 %
6 % input  :      v               : data array
7 %
8 % output :      l               : -1 if v is not a natural number
9 %                                  0 if v is even
10 %                                  1 if v is odd
11 %
12 % version 1.0.0         last change 04.09.1995
13
14 % Gerd Krahmann, IfM Kiel, Aug 1993
15
16 if (length(v)>1)
17   dv=v-fix(v);
18   bad=find(dv~=0);
19   s=size(v);
20   l=ones(s(1),s(2));
21   l(bad)=-ones(1,length(bad));
22   v2=v/2;
23   ev=find(fix(v/2)==v/2);
24   l(ev)=zeros(1,length(ev));
25 else
26   l=0;
27   if fix(v)<v,
28     l=-1;
29   end
30   if fix(v/2)<v/2,
31     l=1;
32   end
33 end
Note: See TracBrowser for help on using the browser.