1 ## Copyright (C) 2006 Muthiah Annamalai <muthiah.annamalai@uta.edu>
3 ## This program is free software; you can redistribute it and/or modify it under
4 ## the terms of the GNU General Public License as published by the Free Software
5 ## Foundation; either version 3 of the License, or (at your option) any later
8 ## This program is distributed in the hope that it will be useful, but WITHOUT
9 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 ## You should have received a copy of the GNU General Public License along with
14 ## this program; if not, see <http://www.gnu.org/licenses/>.
17 ## @deftypefn {Function File} { } fibosplitstream (@var{code})
19 ## Returns the split data stream at the word boundaries.
20 ## Assuming the stream was originally encoded using @code{fiboenco}
21 ## and this routine splits the stream at the points where '11'
22 ## occur together & gives us the code-words which
23 ## can later be decoded from the @code{fibodeco} This however doesnt
24 ## mean that we intend to verify if all the codewords are correct,
25 ## and infact the last symbol in th return list can or can-not be
28 ## A example use of @code{fibosplitstream} would be
32 ## fibodeco(fibosplitstream([fiboenco(randint(1,100,[0 255]))@{:@}]))
33 ## fibodeco(fibosplitstream([fiboenco(1:10)@{:@}]))
37 ## @seealso{fiboenco,fibodeco}
40 function symbols=fibosplitstream(stream)
42 error('usage: fibosplitstream(stream); see help')
50 % Plain & Simple Algorithm. O(N)
51 % Walk till marker '11' or find it.
52 % Then split & save. A little tricky to
53 % handle the edge case_ without tripping over.
61 if(~just_decoded && (stream(i)+prev_bit)==2 )
62 symbols{itr}=[stream(mark:i)];
74 symbols{itr}=stream(mark:end);
80 %!assert(fibodeco(fibosplitstream([fiboenco(1:10){:}])),[1:10])