1 # Created by Octave 3.6.1, Mon May 21 07:07:01 2012 UTC <root@brouzouf>
13 # name: <cell-element>
17 -- Function File: Y = ademodce (X,FS,'amdsb-tc',offset)
18 -- Function File: Y = ademodce (X,FS,'amdsb-tc/costas',offset)
19 -- Function File: Y = ademodce (X,FS,'amdsb-sc')
20 -- Function File: Y = ademodce (X,FS,'amdsb-sc/costas')
21 -- Function File: Y = ademodce (X,FS,'amssb')
22 -- Function File: Y = ademodce (X,FS,'qam')
23 -- Function File: Y = ademodce (X,FS,'qam/cmplx')
24 -- Function File: Y = ademodce (X,FS,'fm',DEV)
25 -- Function File: Y = ademodce (X,FS,'pm',DEV)
26 -- Function File: Y = ademodce (X,[FS,IPHS],...)
27 -- Function File: Y = ademodce (...,NUM,DEN)
28 Baseband demodulator for analog signals. The input signal is
29 specified by X, its sampling frequency by FS and the type of
30 modulation by the third argument, TYP. The default values of FS is
31 1 and TYP is 'amdsb-tc'.
33 If the argument FS is a two element vector, the the first element
34 represents the sampling rate and the second the initial phase.
36 The different types of demodulations that are available are
40 Double-sideband with carrier
43 Double-sideband with carrier and Costas phase locked loop
46 Double-sideband with suppressed carrier
49 Single-sideband with frequency domain Hilbert filtering
52 Quadrature amplitude demodulation. In-phase in odd-columns
53 and quadrature in even-columns
56 Quadrature amplitude demodulation with complex return value.
59 Frequency demodulation
64 Additional arguments are available for the demodulations
65 'amdsb-tc', 'fm', 'pm'. These arguments are
68 The offset in the input signal for the transmitted carrier.
71 The deviation of the phase and frequency modulation
73 It is possible to specify a low-pass filter, by the numerator NUM
74 and denominator DEN that will be applied to the returned vector.
77 See also: ademodce, dmodce
82 # name: <cell-element>
86 Baseband demodulator for analog signals.
90 # name: <cell-element>
97 # name: <cell-element>
101 -- Function File: [M] = amdemod (S, FC, FS)
102 Compute the amplitude demodulation of the signal S with a carrier
103 frequency of FC and a sample frequency of FS.
111 # name: <cell-element>
115 Compute the amplitude demodulation of the signal S with a carrier
120 # name: <cell-element>
127 # name: <cell-element>
131 -- Function File: ammod (X,FC,FS)
132 Create the AM modulation of the signal x with carrier frequency
133 fs. Where x is sample at frequency fs.
135 See also: amdemod, fmmod, fmdemod
141 # name: <cell-element>
145 Create the AM modulation of the signal x with carrier frequency fs.
149 # name: <cell-element>
156 # name: <cell-element>
160 -- Function File: Y = amodce (X,FS,'amdsb-tc',offset)
161 -- Function File: Y = amodce (X,FS,'amdsb-sc')
162 -- Function File: Y = amodce (X,FS,'amssb')
163 -- Function File: Y = amodce (X,FS,'amssb/time',NUM,DEN)
164 -- Function File: Y = amodce (X,FS,'qam')
165 -- Function File: Y = amodce (X,FS,'fm',DEV)
166 -- Function File: Y = amodce (X,FS,'pm',DEV)
167 -- Function File: Y = amodce (X,[FS,IPHS],...)
168 Baseband modulator for analog signals. The input signal is
169 specified by X, its sampling frequency by FS and the type of
170 modulation by the third argument, TYP. The default values of FS is
171 1 and TYP is 'amdsb-tc'.
173 If the argument FS is a two element vector, the the first element
174 represents the sampling rate and the second the initial phase.
176 The different types of modulations that are available are
180 Double-sideband with carrier
183 Double-sideband with suppressed carrier
186 Single-sideband with frequency domain Hilbert filtering
189 Single-sideband with time domain filtering. Hilbert filter is
190 used by default, but the filter can be specified
193 Quadrature amplitude modulation
201 Additional arguments are available for the modulations 'amdsb-tc',
202 'fm, 'pm' and 'amssb/time'. These arguments are
205 The offset in the input signal for the transmitted carrier.
208 The deviation of the phase and frequency modulation
212 The numerator and denominator of the filter transfer function
213 for the time domain filtering of the SSB modulation
216 See also: ademodce, dmodce
221 # name: <cell-element>
225 Baseband modulator for analog signals.
229 # name: <cell-element>
236 # name: <cell-element>
240 -- Function File: apkconst (NSIG)
241 -- Function File: apkconst (NSIG,AMP)
242 -- Function File: apkconst (NSIG,AMP,PHS)
243 -- Function File: apkconst (...,"n")
244 -- Function File: apkconst (...,STR)
245 -- Function File: Y = apkconst (...)
246 Plots a ASK/PSK signal constellation. Argument NSIG is a real
247 vector whose length determines the number of ASK radii in the
248 constellation. The values of vector NSIG determine the number of
249 points in each ASK radii.
251 By default the radii of each ASK modulated level is given by the
252 index of NSIG. The amplitudes can be defined explictly in the
253 variable AMP, which is a vector of the same length as NSIG.
255 By default the first point in each ASK radii has zero phase, and
256 following points are coding in an anti-clockwise manner. If PHS is
257 defined then it is a vector of the same length as NSIG defining
258 the initial phase in each ASK radii.
260 In addition "apkconst" takes two string arguments 'n' and and STR.
261 If the string 'n' is included in the arguments, then a number is
262 printed next to each constellation point giving the symbol value
263 that would be mapped to this point by the "modmap" function. The
264 argument STR is a plot style string (example 'r+') and determines
265 the default gnuplot point style to use for plot points in the
268 If "apskconst" is called with a return argument, then no plot is
269 created. However the return value is a vector giving the in-phase
270 and quadrature values of the symbols in the constellation.
272 See also: dmod, ddemod, modmap, demodmap
277 # name: <cell-element>
281 Plots a ASK/PSK signal constellation.
285 # name: <cell-element>
292 # name: <cell-element>
296 -- Function File: Y = awgn (X,SNR)
297 -- Function File: Y = awgn (X,SNR,PWR)
298 -- Function File: Y = awgn (X,SNR, PWR,SEED)
299 -- Function File: Y = awgn (..., 'TYPE')
300 Add white Gaussian noise to a voltage signal.
302 The input X is assumed to be a real or complex voltage signal. The
303 returned value Y will be the same form and size as X but with
304 Gaussian noise added. Unless the power is specified in PWR, the
305 signal power is assumed to be 0dBW, and the noise of SNR dB will be
306 added with respect to this. If PWR is a numeric value then the
307 signal X is assumed to be PWR dBW, otherwise if PWR is 'measured',
308 then the power in the signal will be measured and the noise added
309 relative to this measured power.
311 If SEED is specified, then the random number generator seed is
312 initialized with this value
314 By default the SNR and PWR are assumed to be in dB and dBW
315 respectively. This default behaviour can be chosen with TYPE set
316 to 'dB'. In the case where TYPE is set to 'linear', PWR is assumed
317 to be in Watts and SNR is a ratio.
324 # name: <cell-element>
328 Add white Gaussian noise to a voltage signal.
332 # name: <cell-element>
339 # name: <cell-element>
343 -- Function File: P = bchpoly ()
344 -- Function File: P = bchpoly (N)
345 -- Function File: P = bchpoly (N,K)
346 -- Function File: P = bchpoly (PRIM,K)
347 -- Function File: P = bchpoly (N,K,PRIM)
348 -- Function File: P = bchpoly (...,PROBE)
349 -- Function File: [P,F] = bchpoly (...)
350 -- Function File: [P,F,C] = bchpoly (...)
351 -- Function File: [P,F,C,PAR] = bchpoly (...)
352 -- Function File: [P,F,C,PAR,T] = bchpoly (...)
353 Calculates the generator polynomials for a BCH coder. Called with
354 no input arguments "bchpoly" returns a list of all of the valid
355 BCH codes for the codeword length 7, 15, 31, 63, 127, 255 and 511.
356 A three column matrix is returned with each row representing a
357 seperate valid BCH code. The first column is the codeword length,
358 the second the message length and the third the error correction
359 capability of the code.
361 Called with a single input argument, "bchpoly" returns the valid
362 BCH codes for the specified codeword length N. The output format
363 is the same as above.
365 When called with two or more arguments, "bchpoly" calculates the
366 generator polynomial of a particular BCH code. The generator
367 polynomial is returned in P as a vector representation of a
368 polynomial in GF(2). The terms of the polynomial are listed
369 least-significant term first.
371 The desired BCH code can be specified by its codeword length N and
372 its message length K. Alternatively, the primitive polynomial over
373 which to calculate the polynomial can be specified as PRIM. If a
374 vector representation of the primitive polynomial is given, then
375 PRIM can be specified as the first argument of two arguments, or
376 as the third argument. However, if an integer representation of the
377 primitive polynomial is used, then the primitive polynomial must be
378 specified as the third argument.
380 When called with two or more arguments, "bchpoly" can also return
381 the factors F of the generator polynomial P, the cyclotomic coset
382 for the Galois field over which the BCH code is calculated, the
383 parity check matrix PAR and the error correction capability T. It
384 should be noted that the parity check matrix is calculated with
385 "cyclgen" and limitations in this function means that the parity
386 check matrix is only available for codeword length upto 63. For
387 codeword length longer than this PAR returns an empty matrix.
389 With a string argument PROBE defined, the action of "bchpoly" is
390 to calculate the error correcting capability of the BCH code
391 defined by N, K and PRIM and return it in P. This is similar to a
392 call to "bchpoly" with zero or one argument, except that only a
393 single code is checked. Any string value for PROBE will force this
396 In general the codeword length N can be expressed as `2^M-1',
397 where M is an integer. However, if [N,K] is a valid BCH code, then
398 a shortened BCH code of the form [N-X,K-X] can be created with the
399 same generator polynomial
402 See also: cyclpoly, encode, decode, cosets
407 # name: <cell-element>
411 Calculates the generator polynomials for a BCH coder.
415 # name: <cell-element>
422 # name: <cell-element>
426 -- Function File: D = bi2de (B)
427 -- Function File: D = bi2de (B,F)
428 -- Function File: D = bi2de (B,P)
429 -- Function File: D = bi2de (B,P,F)
430 Convert bit matrix to a vector of integers
432 Each row of the matrix B is treated as a single integer represented
433 in binary form. The elements of B, must therefore be '0' or '1'
435 If P is defined then it is treated as the base of the decomposition
436 and the elements of B must then lie between '0' and 'p-1'.
438 The variable F defines whether the first or last element of B is
439 considered to be the most-significant. Valid values of F are
440 'right-msb' or 'left-msb'. By default F is 'right-msb'.
448 # name: <cell-element>
452 Convert bit matrix to a vector of integers
457 # name: <cell-element>
464 # name: <cell-element>
468 -- Function File: [NUM, RATE] = biterr (A,B)
469 -- Function File: [NUM, RATE] = biterr (...,K)
470 -- Function File: [NUM, RATE] = biterr (...,FLAG)
471 -- Function File: [NUM, RATE IND] = biterr (...)
472 Compares two matrices and returns the number of bit errors and the
473 bit error rate. The binary representations of the variables A and
474 B are treated and A and B can be either:
477 In this case both matrices must be the same size and then by
478 default the the return values NUM and RATE are the overall
479 number of bit errors and the overall bit error rate.
482 In this case the column vector is used for bit error
483 comparision column-wise with the matrix. The returned values
484 NUM and RATE are then row vectors containing the num of bit
485 errors and the bit error rate for each of the column-wise
486 comparisons. The number of rows in the matrix must be the
487 same as the length of the column vector
490 In this case the row vector is used for bit error comparision
491 row-wise with the matrix. The returned values NUM and RATE
492 are then column vectors containing the num of bit errors and
493 the bit error rate for each of the row-wise comparisons. The
494 number of columns in the matrix must be the same as the
495 length of the row vector
497 This behaviour can be overridden with the variable FLAG. FLAG can
498 take the value 'column-wise', 'row-wise' or 'overall'. A
499 column-wise comparision is not possible with a row vector and
502 By default the number of bits in each symbol is assumed to be give
503 by the number required to represent the maximum value of A and B.
504 The number of bits to represent a symbol can be overridden by the
510 # name: <cell-element>
514 Compares two matrices and returns the number of bit errors and the bit
519 # name: <cell-element>
526 # name: <cell-element>
530 -- Function File: Y = bsc (DATA, P)
531 Send DATA into a binary symetric channel with probability P of
532 error one each symbol.
537 # name: <cell-element>
541 Send DATA into a binary symetric channel with probability P of error
546 # name: <cell-element>
553 # name: <cell-element>
557 -- Function File: comms ('help')
558 -- Function File: comms ('info')
559 -- Function File: comms ('info', MOD)
560 -- Function File: comms ('test')
561 -- Function File: comms ('test', MOD)
562 Manual and test code for the Octave Communications toolbox. There
563 are 5 possible ways to call this function.
566 Display this help message. Called with no arguments, this
567 function also displays this help message
570 Open the Commumications toolbox manual
572 `comms ('info', MOD)'
573 Open the Commumications toolbox manual at the section
577 Run all of the test code for the Communications toolbox.
579 `comms ('test', MOD)'
580 Run only the test code for the Communications toolbox in the
583 Valid values for the varibale MOD are
589 The random signal generation and analysis package
592 The source coding functions of the package
595 The block coding functions
598 The convolution coding package
601 The modulation package
604 The special filter functions
607 The Galois fields package
609 Please note that this function file should be used as an example
610 of the use of this toolbox.
615 # name: <cell-element>
619 Manual and test code for the Octave Communications toolbox.
623 # name: <cell-element>
630 # name: <cell-element>
634 -- Function File: Y = compand (X, MU, V, 'mu/compressor')
635 -- Function File: Y = compand (X, MU, V, 'mu/expander')
636 -- Function File: Y = compand (X, MU, V, 'A/compressor')
637 -- Function File: Y = compand (X, MU, V, 'A/expander')
638 Compresses and expanding the dynamic range of a signal using a
639 mu-law or or A-law algorithm.
641 The mu-law compressor/expander for reducing the dynamic range, is
642 used if the fourth argument of "compand" starts with 'mu/'.
643 Whereas the A-law compressor/expander is used if "compand" starts
644 with 'A/'. The mu-law algorithm uses the formulation
647 V log (1 + \mu/V |x|)
648 y = -------------------- sgn(x)
651 while the A-law algorithm used the formulation
654 / A / (1 + log A) x, 0 <= |x| <= V/A
656 y = < V ( 1 + log (A/V |x|) )
657 | ----------------------- sgn(x), V/A < |x| <= V
660 Neither converts from or to audio file ulaw format. Use mu2lin or
664 See also: m2ulin, lin2mu
669 # name: <cell-element>
673 Compresses and expanding the dynamic range of a signal using a mu-law or
678 # name: <cell-element>
685 # name: <cell-element>
689 -- Function File: X = convenc (M, G, K)
690 Compute output of an (n, K, L) convolutional encoder with vector
691 input M and matrix of generator polynomials G.
693 The input vector M can be of arbitrary length. G is a matrix with
694 n rows and K*(L+1) columns. The rows of G are the generator
695 polynomials for each of the n output bits (per K input bits).
697 The output is a vector whose length is
698 n*floor([length(M)+K*(L+1)-1]/K). If unspecified, K defaults to 1.
700 Example 1: Compute the output from a (2, 1, 2) convolutional
702 m = [ 1 1 0 1 1 1 0 0 1 0 0 0];
705 convenc (m, [g1; g2])
706 => [1 1 0 1 0 1 0 0 0 1 1 0 0 1 1 1 1 1 1 0 1 1 0 0 0 0 0 0]
708 Example 2: Compute the output from a (3, 2, 1) convolutional
710 m = [0 1 1 0 0 0 1 1 ];
714 convenc (m, [g1; g2; g3], 2)
715 => [1 1 1 1 1 1 1 1 0 1 0 1]
717 *Caution:*: this function is not compatible with MATLAB's
723 # name: <cell-element>
727 Compute output of an (n, K, L) convolutional encoder with vector input
732 # name: <cell-element>
739 # name: <cell-element>
743 -- Function File: cosets (M, PRIM)
744 Finds the elements of GF(2^M) with primitive polynomial PRIM, that
745 share the same minimum polynomial. Returns a cell array of the
746 paratitioning of GF(2^M).
751 # name: <cell-element>
755 Finds the elements of GF(2^M) with primitive polynomial PRIM, that
760 # name: <cell-element>
767 # name: <cell-element>
771 -- Function File: B = de2bi (D)
772 -- Function File: B = de2bi (D,N)
773 -- Function File: B = de2bi (D,N,P)
774 -- Function File: B = de2bi (D,N,P,F)
775 Convert a non-negative integer to bit vector.
777 The variable D must be a vector of non-negative integers. "de2bi"
778 then returns a matrix where each row represents the binary
779 representation of elements of D. If N is defined then the returned
780 matrix will have N columns. This number of columns can be either
781 larger than the minimum needed and zeros will be added to the msb
782 of the binary representation or smaller than the minimum in which
783 case the least-significant part of the element is returned.
785 If P is defined then it is used as the base for the decomposition
786 of the returned values. That is the elements of the returned value
787 are between '0' and 'p-1'.
789 The variable F defines whether the first or last element of B is
790 considered to be the most-significant. Valid values of F are
791 'right-msb' or 'left-msb'. By default F is 'right-msb'.
799 # name: <cell-element>
803 Convert a non-negative integer to bit vector.
807 # name: <cell-element>
814 # name: <cell-element>
818 -- Function File: MSG = decode (CODE,N,K)
819 -- Function File: MSG = decode (CODE,N,K,TYP)
820 -- Function File: MSG = decode (CODE,N,K,TYP,OPT1)
821 -- Function File: MSG = decode (CODE,N,K,TYP,OPT1,OPT2)
822 -- Function File: [MSG, ERR] = decode (...)
823 -- Function File: [MSG, ERR, CCODE] = decode (...)
824 -- Function File: [MSG, ERR, CCODE, CERR] = decode (...)
825 Top level block decoder. This function makes use of the lower level
826 functions such as "cyclpoly", "cyclgen", "hammgen", and "bchenco".
827 The coded message to decode is pass in CODE, the codeword length
828 is N and the message length is K. This function is used to decode
829 messages using either:
831 A [n,k] linear block code defined by a generator matrix
833 A [n,k] cyclic code defined by a generator polynomial
835 A [n,k] Hamming code defined by a primitive polynomial
837 A [n,k] BCH code code defined by a generator polynomial
839 The type of coding to use is defined by the variable TYP. This
840 variable is a string taking one of the values
842 `'linear' or 'linear/binary''
843 A linear block code is assumed with the message MSG being in a
844 binary format. In this case the argument OPT1 is the generator
845 matrix, and is required. Additionally, OPT2 containing the
846 syndrome lookup table (see "syndtable") can also be passed.
848 `'cyclic' or 'cyclic/binary''
849 A cyclic code is assumed with the message MSG being in a
850 binary format. The generator polynomial to use can be defined
851 in OPT1. The default generator polynomial to use will be
852 "cyclpoly(N,K)". Additionally, OPT2 containing the syndrome
853 lookup table (see "syndtable") can also be passed.
855 `'hamming' or 'hamming/binary''
856 A Hamming code is assumed with the message MSG being in a
857 binary format. In this case N must be of an integer of the
858 form `2^M-1', where M is an integer. In addition K must be
859 `N-M'. The primitive polynomial to use can be defined in
860 OPT1. The default primitive polynomial to use is the same as
861 defined by "hammgen". The variable OPT2 should not be defined.
863 `'bch' or 'bch/binary''
864 A BCH code is assumed with the message MSG being in a binary
865 format. The primitive polynomial to use can be defined in
866 OPT2. The error correction capability of the code can also
867 be defined in OPT1. Use the empty matrix [] to let the error
868 correction capability take the default value.
870 In addition the argument 'binary' above can be replaced with
871 'decimal', in which case the message is assumed to be a decimal
872 vector, with each value representing a symbol to be coded. The
873 binary format can be in two forms
876 Each row of this matrix represents a symbol to be decoded
878 `A vector with length divisible by N'
879 The coded symbols are created from groups of N elements of
882 The decoded message is return in MSG. The number of errors
883 encountered is returned in ERR. If the coded message format is
884 'decimal' or a 'binary' matrix, then ERR is a column vector having
885 a length equal to the number of decoded symbols. If CODE is a
886 'binary' vector, then ERR is the same length as MSG and indicated
887 the number of errors in each symbol. If the value ERR is positive
888 it indicates the number of errors corrected in the corresponding
889 symbol. A negative value indicates an uncorrectable error. The
890 corrected code is returned in CCODE in a similar format to the
891 coded message MSG. The variable CERR contains similar data to ERR
894 It should be noted that all internal calculations are performed in
895 the binary format. Therefore for large values of N, it is
896 preferable to use the binary format to pass the messages to avoid
897 possible rounding errors. Additionally, if repeated calls to
898 "decode" will be performed, it is often faster to create a
899 generator matrix externally with the functions "hammgen" or
900 "cyclgen", rather than let "decode" recalculate this matrix at
901 each iteration. In this case TYP should be 'linear'. The exception
902 to this case is BCH codes, where the required syndrome table is
903 too large. The BCH decoder, decodes directly from the polynomial
904 never explicitly forming the syndrome table.
907 See also: encode, cyclgen, cyclpoly, hammgen, bchdeco, bchpoly,
913 # name: <cell-element>
917 Top level block decoder.
921 # name: <cell-element>
928 # name: <cell-element>
932 -- Function File: DEINTRLVD = deintrlv (DATA, ELEMENTS)
933 Restore elements of DATA according to ELEMENTS.
941 # name: <cell-element>
945 Restore elements of DATA according to ELEMENTS.
949 # name: <cell-element>
956 # name: <cell-element>
960 -- Function File: z = demodmap (Y,FD,FS,'ask',M)
961 -- Function File: z = demodmap (Y,FD,FS,'fsk',M,TONE)
962 -- Function File: z = demodmap (Y,FD,FS,'msk')
963 -- Function File: z = demodmap (Y,FD,FS,'psk',M)
964 -- Function File: z = demodmap (Y,FD,FS,'qask',M)
965 -- Function File: z = demodmap (Y,FD,FS,'qask/cir',NSIG,AMP,PHS)
966 -- Function File: z = demodmap (Y,FD,FS,'qask/arb',INPHASE,QUADR)
967 -- Function File: z = demodmap (Y,FD,FS,'qask/arb',MAP)
968 -- Function File: z = demodmap (Y,[FD, OFF],...)
969 Demapping of an analog signal to a digital signal. The function
970 "demodmap" must have at least three input arguments and one output
971 argument. Argument Y is a complex variable representing the analog
972 signal to be demapped. The variables FD and FS are the sampling
973 rate of the of digital signal and the sampling rate of the analog
974 signal respectively. It is required that `FS/FD' is an integer.
976 The available mapping of the digital signal are
979 Amplitude shift keying
982 Frequency shift keying
993 Quadraure amplitude shift keying
995 In addition the 'qask', 'qsk' and 'qam' method can be modified
996 with the flags '/cir' or '/arb'. That is 'qask/cir' and
997 'qask/arb', etc are valid methods and give circular- and
998 arbitrary-qask mappings respectively. Also the method 'fsk' and
999 'msk' can be modified with the flag '/max', in which case Y is
1000 assumed to be a matrix with M columns, representing the symbol
1003 The variable M is the order of the modulation to use. By default
1004 this is 2, and in general should be specified.
1006 For 'qask/cir', the additional arguments are the same as for
1007 "apkconst", and you are referred to "apkconst" for the definitions
1008 of the additional variables.
1010 For 'qask/arb', the additional arguments INPHASE and QUADR give
1011 the in-phase and quadrature components of the mapping, in a
1012 similar mapping to the outputs of "qaskenco" with one argument.
1013 Similar MAP represents the in-phase and quadrature components of
1014 the mapping as the real and imaginary parts of the variable MAP.
1016 See also: modmap, ddemodce, ademodce, apkconst, qaskenco
1021 # name: <cell-element>
1025 Demapping of an analog signal to a digital signal.
1029 # name: <cell-element>
1036 # name: <cell-element>
1040 -- Function File: egolaydec (R)
1041 Given R, the received Extended Golay code, this function tries to
1042 decode R using the Extended Golay code parity check matrix.
1043 Extended Golay code (24,12) which can correct upto 3 errors.
1045 The received code R, needs to be of length Nx24, for encoding. We
1046 can decode several codes at once, if they are stacked as a matrix
1047 of 24columns, each code in a separate row.
1049 The generator G used in here is same as obtained from the function
1052 The function returns the error-corrected code word from the
1053 received word. If decoding failed, the second return value is 1,
1056 Extended Golay code (24,12) which can correct upto 3 errors.
1057 Decoding algorithm follows from Lin & Costello.
1059 Ref: Lin & Costello, pg 128, Ch4, 'Error Control Coding', 2nd ed,
1062 M=[rand(10,12)>0.5];
1064 C1(:,1)=mod(C1(:,1)+1,2)
1068 See also: egolaygen, egolayenc
1073 # name: <cell-element>
1077 Given R, the received Extended Golay code, this function tries to
1082 # name: <cell-element>
1089 # name: <cell-element>
1093 -- Function File: egolayenc (M)
1094 Given M, encode M using the Extended Golay code.
1096 The message M, needs to be of size Nx12, for encoding. We can
1097 encode several messages, into codes at once, if they are stacked
1098 in the order suggested.
1100 The generator G used in here is same as obtained from the function
1101 egolaygen. Extended Golay code (24,12) which can correct upto 3
1104 M=(rand(10,12)>0.5);
1108 See also: egolaygen, egolaydec
1113 # name: <cell-element>
1117 Given M, encode M using the Extended Golay code.
1121 # name: <cell-element>
1128 # name: <cell-element>
1132 -- Function File: egolaygen ()
1133 Returns the Extended Golay code (24,12) generator matrix, which
1134 can correct upto 3 errors. The second argument is the partiy check
1135 matrix, for this code.
1138 See also: egolaydec, egolayenc
1143 # name: <cell-element>
1147 Returns the Extended Golay code (24,12) generator matrix, which can
1152 # name: <cell-element>
1159 # name: <cell-element>
1163 -- Function File: CODE = encode (MSG,N,K)
1164 -- Function File: CODE = encode (MSG,N,K,TYP)
1165 -- Function File: CODE = encode (MSG,N,K,TYP,OPT)
1166 -- Function File: [CODE, ADDED] = encode (...)
1167 Top level block encoder. This function makes use of the lower level
1168 functions such as "cyclpoly", "cyclgen", "hammgen", and "bchenco".
1169 The message to code is pass in MSG, the codeword length is N and
1170 the message length is K. This function is used to encode messages
1173 A [n,k] linear block code defined by a generator matrix
1175 A [n,k] cyclic code defined by a generator polynomial
1177 A [n,k] Hamming code defined by a primitive polynomial
1179 A [n,k] BCH code code defined by a generator polynomial
1181 The type of coding to use is defined by the variable TYP. This
1182 variable is a string taking one of the values
1184 `'linear' or 'linear/binary''
1185 A linear block code is assumed with the coded message CODE
1186 being in a binary format. In this case the argument OPT is
1187 the generator matrix, and is required.
1189 `'cyclic' or 'cyclic/binary''
1190 A cyclic code is assumed with the coded message CODE being in
1191 a binary format. The generator polynomial to use can be
1192 defined in OPT. The default generator polynomial to use will
1195 `'hamming' or 'hamming/binary''
1196 A Hamming code is assumed with the coded message CODE being
1197 in a binary format. In this case N must be of an integer of
1198 the form `2^M-1', where M is an integer. In addition K must
1199 be `N-M'. The primitive polynomial to use can be defined in
1200 OPT. The default primitive polynomial to use is the same as
1201 defined by "hammgen".
1203 `'bch' or 'bch/binary''
1204 A BCH code is assumed with the coded message CODE being in a
1205 binary format. The generator polynomial to use can be defined
1206 in OPT. The default generator polynomial to use will be
1209 In addition the argument 'binary' above can be replaced with
1210 'decimal', in which case the message is assumed to be a decimal
1211 vector, with each value representing a symbol to be coded. The
1212 binary format can be in two forms
1215 Each row of this matrix represents a symbol to be coded
1218 The symbols are created from groups of K elements of this
1219 vector. If the vector length is not divisble by K, then
1220 zeros are added and the number of zeros added is returned in
1223 It should be noted that all internal calculations are performed in
1224 the binary format. Therefore for large values of N, it is
1225 preferable to use the binary format to pass the messages to avoid
1226 possible rounding errors. Additionally, if repeated calls to
1227 "encode" will be performed, it is often faster to create a
1228 generator matrix externally with the functions "hammgen" or
1229 "cyclgen", rather than let "encode" recalculate this matrix at
1230 each iteration. In this case TYP should be 'linear'. The exception
1231 to this case is BCH codes, whose encoder is implemented directly
1232 from the polynomial and is significantly faster.
1235 See also: decode, cyclgen, cyclpoly, hammgen, bchenco, bchpoly
1240 # name: <cell-element>
1244 Top level block encoder.
1248 # name: <cell-element>
1255 # name: <cell-element>
1259 -- Function File: eyediagram (X,N)
1260 -- Function File: eyediagram (X,N,PER)
1261 -- Function File: eyediagram (X,N,PER,OFF)
1262 -- Function File: eyediagram (X,N,PER,OFF,STR)
1263 -- Function File: eyediagram (X,N,PER,OFF,STR,H)
1264 -- Function File: H = eyediagram (...)
1265 Plot the eye-diagram of a signal. The signal X can be either in one
1269 In this case the signal is assumed to be real and represented
1270 by the vector X. A single eye-diagram representing this
1274 In this case the in-phase and quadrature components of the
1275 signal are plotted seperately.
1277 A matrix with two columns
1278 In this case the first column represents the in-phase and the
1279 second the quadrature components of a complex signal.
1281 Each line of the eye-diagram has N elements and the period is
1282 assumed to be given by PER. The time axis is then [-PER/2 PER/2].
1283 By default PER is 1.
1285 By default the signal is assumed to start at -PER/2. This can be
1286 overridden by the OFF variable, which gives the number of samples
1287 to delay the signal.
1289 The string STR is a plot style string (example 'r+'), and by
1290 default is the default gnuplot line style.
1292 The figure handle to use can be defined by H. If H is not given,
1293 then the next available figure handle is used. The figure handle
1294 used in returned on HOUT.
1296 See also: scatterplot
1301 # name: <cell-element>
1305 Plot the eye-diagram of a signal.
1309 # name: <cell-element>
1316 # name: <cell-element>
1320 -- Function File: fibodeco (CODE)
1321 Returns the decoded fibonacci value from the binary vectors CODE.
1322 Universal codes like fibonacci codes Have a useful synchronization
1323 property, only for 255 maximum value we have designed these
1324 routines. We assume user has partitioned the code into several
1325 unique segments based on the suffix property of unique strings
1326 "11" and we just decode the parts. Partitioning the stream is as
1327 simple as identifying the "11" pairs that occur, at the
1328 terminating ends. This system implements the standard binaary
1329 Fibonacci codes, which means that row vectors can only contain 0
1330 or 1. Ref: `http://en.wikipedia.org/wiki/Fibonacci_coding'
1332 fibodeco({[0 1 0 0 1 1]}) %decoded to 10
1333 fibodeco({[1 1],[0 1 1],[0 0 1 1],[1 0 1 1]}) %[1:4]
1340 # name: <cell-element>
1344 Returns the decoded fibonacci value from the binary vectors CODE.
1348 # name: <cell-element>
1355 # name: <cell-element>
1359 -- Function File: fiboenco (NUM)
1360 Returns the cell-array of encoded fibonacci value from the column
1361 vectors NUM. Universal codes like fibonacci codes have a useful
1362 synchronization property, only for 255 maximum value we have
1363 designed these routines. We assume user has partitioned the code
1364 into several unique segments based on the suffix property of
1365 unique elements [1 1] and we just decode the parts. Partitioning
1366 the stream is as simple as identifying the [1 1] pairs that occur,
1367 at the terminating ends. This system implements the standard
1368 binaary Fibonacci codes, which means that row vectors can only
1369 contain 0 or 1. Ref: http://en.wikipedia.org/wiki/Fibonacci_coding
1370 Ugly O(k.N^2) encoder.Ref: Wikipedia article accessed March, 2006.
1371 `http://en.wikipedia.org/wiki/Fibonacci_coding', UCI Data
1372 Compression Book, `http://www.ics.uci.edu/~dan/pubs/DC-Sec3.html',
1373 (accessed October 2006)
1375 fiboenco(10) #= code is {[ 0 1 0 0 1 1]}
1376 fiboenco(1:4) #= code is {[1 1],[0 1 1],[0 0 1 1],[1 0 1 1]}
1383 # name: <cell-element>
1387 Returns the cell-array of encoded fibonacci value from the column
1392 # name: <cell-element>
1399 # name: <cell-element>
1403 -- Function File: fibosplitstream (CODE)
1404 Returns the split data stream at the word boundaries. Assuming
1405 the stream was originally encoded using `fiboenco' and this
1406 routine splits the stream at the points where '11' occur together
1407 & gives us the code-words which can later be decoded from the
1408 `fibodeco' This however doesnt mean that we intend to verify if
1409 all the codewords are correct, and infact the last symbol in th
1410 return list can or can-not be a valid codeword.
1412 A example use of `fibosplitstream' would be
1414 fibodeco(fibosplitstream([fiboenco(randint(1,100,[0 255])){:}]))
1415 fibodeco(fibosplitstream([fiboenco(1:10){:}]))
1417 See also: fiboenco, fibodeco
1423 # name: <cell-element>
1427 Returns the split data stream at the word boundaries.
1431 # name: <cell-element>
1438 # name: <cell-element>
1442 -- Function File: fmdemod (X,FC,FS)
1443 Create the FM demodulation of the signal x with carrier frequency
1444 fs. Where x is sample at frequency fs.
1446 See also: ammod, amdemod, fmmod
1452 # name: <cell-element>
1456 Create the FM demodulation of the signal x with carrier frequency fs.
1460 # name: <cell-element>
1467 # name: <cell-element>
1471 -- Function File: fmmod (X,FC,FS)
1472 Create the FM modulation of the signal x with carrier frequency
1473 fs. Where x is sample at frequency fs.
1475 See also: ammod, fmdemod, amdemod
1481 # name: <cell-element>
1485 Create the FM modulation of the signal x with carrier frequency fs.
1489 # name: <cell-element>
1496 # name: <cell-element>
1500 -- Function File: PAR = gen2par (GEN)
1501 -- Function File: GEN = gen2par (PAR)
1502 Converts binary generator matrix GEN to the parity chack matrix
1503 PAR and visa-versa. The input matrix must be in standard form.
1504 That is a generator matrix must be k-by-n and in the form [eye(k)
1505 P] or [P eye(k)], and the parity matrix must be (n-k)-by-n and of
1506 the form [eye(n-k) P'] or [P' eye(n-k)].
1509 See also: cyclgen, hammgen
1514 # name: <cell-element>
1518 Converts binary generator matrix GEN to the parity chack matrix PAR and
1523 # name: <cell-element>
1530 # name: <cell-element>
1534 -- Function File: [Z] = genqamdemod(Y,CONST)
1535 Compute the general quadrature amplitude demodulation of y.
1537 See also: genqammod, qammod, qamdemod
1543 # name: <cell-element>
1547 Compute the general quadrature amplitude demodulation of y.
1551 # name: <cell-element>
1558 # name: <cell-element>
1562 -- Function File: Y = genqammod (X, C)
1563 Modulates an information sequence of intergers X in the range `[0
1564 ... M-1]' onto a quadrature amplitude modulated signal Y, where
1565 `M = length(c) - 1' and C is a 1D vector specifing the signal
1566 constellation mapping to be used. An example of combined 4PAM-4PSK
1569 d = randint(1,1e4,8);
1570 c = [1+j -1+j -1-j 1-j 1+sqrt(3) j*(1+sqrt(3)) -1-sqrt(3) -j*(1+sqrt(3))];
1575 See also: genqamdemod
1580 # name: <cell-element>
1584 Modulates an information sequence of intergers X in the range `[0 .
1588 # name: <cell-element>
1595 # name: <cell-element>
1599 -- Function File: gftable (M, PRIMPOLY)
1600 This function exists for compatiability with matlab. As the octave
1601 galois fields store a copy of the lookup tables for every field in
1602 use internally, there is no need to use this function.
1610 # name: <cell-element>
1614 This function exists for compatiability with matlab.
1618 # name: <cell-element>
1625 # name: <cell-element>
1629 -- Function File: W = gfweight (GEN)
1630 -- Function File: W = gfweight (GEN,'gen')
1631 -- Function File: W = gfweight (PAR,'par')
1632 -- Function File: W = gfweight (P,n)
1633 Calculate the minimum weight or distance of a linear block code.
1634 The code can be either defined by its generator or parity check
1635 matrix, or its generator polynomial. By default if the first
1636 argument is a matrix, it is assumed to be the generator matrix of
1637 the code. The type of the matrix can be defined by a flag 'gen'
1638 for the generator matrix or 'par' for the parity check matrix.
1640 If the first argument is a vector, it is assumed that it defines
1641 the generator polynomial of the code. In this case a second
1642 argument is required that defines the codeword length.
1645 See also: hammgen, cyclpoly, bchpoly
1650 # name: <cell-element>
1654 Calculate the minimum weight or distance of a linear block code.
1658 # name: <cell-element>
1665 # name: <cell-element>
1669 -- Function File: golombdeco (CODE, M)
1670 Returns the Golomb decoded signal vector using CODE and M.
1671 Compulsory m is need to be specified. A restrictions is that a
1672 signal set must strictly be non-negative. The value of code is a
1673 cell array of row-vectors which have the encoded golomb value for
1674 a single sample. The Golomb algorithm is, used to encode the
1675 'code' and only that can be meaningfully decoded. CODE is assumed
1676 to have been of format generated by the function `golombenco'.
1677 Also the parameter M need to be a non-zero number, unless which it
1678 makes divide-by-zero errors. This function works backward the
1679 Golomb algorithm see `golombenco' for more detials on that.
1680 Reference: Solomon Golomb, Run length Encodings, 1966 IEEE Trans
1683 An exmaple of the use of `golombdeco' is
1684 golombdeco(golombenco(1:4,2),2)
1686 See also: golombenco
1691 # name: <cell-element>
1695 Returns the Golomb decoded signal vector using CODE and M.
1699 # name: <cell-element>
1706 # name: <cell-element>
1710 -- Function File: golombenco (SIG, M)
1711 Returns the Golomb coded signal as cell array. Also total length
1712 of output code in bits can be obtained. This function uses a M
1713 need to be supplied for encoding signal vector into a golomb coded
1714 vector. A restrictions is that a signal set must strictly be
1715 non-negative. Also the parameter M need to be a non-zero number,
1716 unless which it makes divide-by-zero errors. The Golomb algorithm
1717 [1], is used to encode the data into unary coded quotient part
1718 which is represented as a set of 1's separated from the K-part
1719 (binary) using a zero. This scheme doesnt need any kind of
1720 dictionaries, it is a parameterized prefix codes. Implementation
1721 is close to O(N^2), but this implementation *may be* sluggish,
1722 though correct. Details of the scheme are, to encode the
1723 remainder(r of number N) using the floor(log2(m)) bits when rem is
1724 in range 0:(2^ceil(log2(m)) - N), and encode it as
1725 r+(2^ceil(log2(m)) - N), using total of 2^ceil(log2(m)) bits in
1726 other instance it doesnt belong to case 1. Quotient is coded
1727 simply just using the unary code. Also accroding to [2] Golomb
1728 codes are optimal for sequences using the bernoulli probability
1729 model: P(n)=p^n-1.q & p+q=1, and when M=[1/log2(p)], or P=2^(1/M).
1731 Reference: 1. Solomon Golomb, Run length Encodings, 1966 IEEE Trans
1732 Info' Theory. 2. Khalid Sayood, Data Compression, 3rd Edition
1734 An exmaple of the use of `golombenco' is
1736 golombenco(1:10,2) #
1738 See also: golombdeco
1743 # name: <cell-element>
1747 Returns the Golomb coded signal as cell array.
1751 # name: <cell-element>
1758 # name: <cell-element>
1762 -- Function File: H = hammgen (M)
1763 -- Function File: H = hammgen (M,P)
1764 -- Function File: [H,G] = hammgen (...)
1765 -- Function File: [H,G,N,K] = hammgen (...)
1766 Produce the parity check and generator matrices of a Hamming code.
1767 The variable M defines the [N,K] Hamming code where `N = 2 ^ M -
1768 1' and `K = N - M'. M must be between 3 and 16.
1770 The parity check matrix is generated relative to the primitive
1771 polynomial of GF(2^M). If P is specified the default primitive
1772 polynomial of GF(2^M) is overridden. P must be a valid primitive
1773 polynomial of the correct order for GF(2^M).
1775 The parity check matrix is returned in the M by N matrix H, and if
1776 requested the generator matrix is returned in the K by N matrix G.
1784 # name: <cell-element>
1788 Produce the parity check and generator matrices of a Hamming code.
1792 # name: <cell-element>
1799 # name: <cell-element>
1803 -- Function File: OUTDATA = helintrlv (DATA, COL, NGRP,STP)
1806 See also: heldeintrlv
1812 # name: <cell-element>
1820 # name: <cell-element>
1827 # name: <cell-element>
1831 -- Function File: OUTDATA = helscandeintrlv (DATA, NROWS, NCOLS,NSHIFT)
1834 See also: helscandeintrlv
1840 # name: <cell-element>
1848 # name: <cell-element>
1855 # name: <cell-element>
1859 -- Function File: OUTDATA = helscanintrlv (DATA, NROWS, NCOLS,NSHIFT)
1862 See also: helscandeintrlv
1868 # name: <cell-element>
1876 # name: <cell-element>
1883 # name: <cell-element>
1887 -- Function File: SIG = huffmandeco (HCODE, DICT)
1888 Decode signal encoded by `huffmanenco'.
1890 This function uses a dict built from the `huffmandict' and uses it
1891 to decode a signal list into a huffman list. A restriction is that
1892 HCODE is expected to be a binary code
1894 The returned SIG set that strictly belongs in the range `[1,N]'
1895 with `N = length(DICT)'. Also DICT can only be from the
1896 `huffmandict' routine. Whenever decoding fails, those signal
1897 values a re indicated by `-1', and we successively try to restart
1898 decoding from the next bit that hasn't failed in decoding,
1899 ad-infinitum. An example of the use of `huffmandeco' is:
1901 hd = huffmandict (1:4, [0.5 0.25 0.15 0.10]);
1902 hcode = huffmanenco (1:4, hd);
1903 back = huffmandeco (hcode, hd)
1906 See also: huffmandict, huffmanenco
1912 # name: <cell-element>
1916 Decode signal encoded by `huffmanenco'.
1920 # name: <cell-element>
1927 # name: <cell-element>
1931 -- Function File: huffmandict (SYMB, PROB)
1932 -- Function File: huffmandict (SYMB, PROB, TOGGLE)
1933 -- Function File: huffmandict (SYMB, PROB, TOGGLE, MINVAR)
1934 Builds a Huffman code, given a probability list. The Huffman codes
1935 per symbol are output as a list of strings-per-source symbol. A
1936 zero probability symbol is NOT assigned any codeword as this
1937 symbol doesn't occur in practice anyway.
1939 TOGGLE is an optional argument with values 1 or 0, that starts
1940 building a code based on 1's or 0's, defaulting to 0. Also MINVAR
1941 is a boolean value that is useful in choosing if you want to
1942 optimize buffer for transmission in the applications of Huffman
1943 coding, however it doesn't affect the type or average codeword
1944 length of the generated code. An example of the use of
1947 huffmandict(symbols, [0.5 0.25 0.15 0.1]) => CW(0,10,111,110)
1948 huffmandict(symbols, 0.25*ones(1,4)) => CW(11,10,01,00)
1950 prob=[0.5 0 0.25 0.15 0.1]
1951 dict=huffmandict(1:5,[0.5 0 0.25 0.15 0.1],1)
1955 x = [0.20000 0.40000 0.20000 0.10000 0.10000];
1956 #illustrates the minimum variance thing.
1957 huffmandict(1,x,0,true) #min variance tree.
1958 huffmandict(1,x) #normal huffman tree.
1960 Reference: Dr.Rao's course EE5351 Digital Video Coding, at
1963 See also: huffmandeco, huffmanenco
1969 # name: <cell-element>
1973 Builds a Huffman code, given a probability list.
1977 # name: <cell-element>
1984 # name: <cell-element>
1988 -- Function File: huffmanenco (SIG, DICT)
1989 Returns the Huffman encoded signal using DICT. This function uses
1990 a DICT built from the `huffmandict' and uses it to encode a signal
1991 list into a huffman list. A restrictions is that a signal set must
1992 strictly belong in the range `[1,N]' with `N = length(dict)'.
1993 Also DICT can only be from the `huffmandict' routine. An exmaple
1994 of the use of `huffmanenco' is
1996 hd = huffmandict (1:4, [0.5 0.25 0.15 0.10]);
1997 huffmanenco (1:4, hd);
1998 => [1 0 1 0 0 0 0 0 1]
2000 See also: huffmandict, huffmandeco
2006 # name: <cell-element>
2010 Returns the Huffman encoded signal using DICT.
2014 # name: <cell-element>
2021 # name: <cell-element>
2025 -- Function File: INTRLVD = intrlv (DATA, ELEMENTS)
2026 Interleaved elements of DATA according to ELEMENTS.
2034 # name: <cell-element>
2038 Interleaved elements of DATA according to ELEMENTS.
2042 # name: <cell-element>
2049 # name: <cell-element>
2053 -- Function File: [TABLE, CODES] = lloyds (SIG,INIT_CODES)
2054 -- Function File: [TABLE, CODES] = lloyds (SIG,LEN)
2055 -- Function File: [TABLE, CODES] = lloyds (SIG,...,TOL)
2056 -- Function File: [TABLE, CODES] = lloyds (SIG,...,TOL,TYPE)
2057 -- Function File: [TABLE, CODES, DIST] = lloyds (...)
2058 -- Function File: [TABLE, CODES, DIST, RELDIST] = lloyds (...)
2059 Optimize the quantization table and codes to reduce distortion.
2060 This is based on the article by Lloyd
2062 S. Lloyd _Least squared quantization in PCM_, IEEE Trans Inform
2063 Thoery, Mar 1982, no 2, p129-137
2065 which describes an iterative technique to reduce the quantization
2066 error by making the intervals of the table such that each interval
2067 has the same area under the PDF of the training signal SIG. The
2068 initial codes to try can either be given in the vector INIT_CODES
2069 or as scalar LEN. In the case of a scalar the initial codes will
2070 be an equi-spaced vector of length LEN between the minimum and
2071 maximum value of the training signal.
2073 The stopping criteria of the iterative algorithm is given by
2075 abs(DIST(n) - DIST(n-1)) < max(TOL, abs(EPS*max(SIG))
2077 By default TOL is 1.e-7. The final input argument determines how
2078 the updated table is created. By default the centroid of the
2079 values of the training signal that fall within the interval
2080 described by CODES are used to update TABLE. If TYPE is any other
2081 string than "centroid", this behaviour is overriden and TABLE is
2084 TABLE = (CODE(2:length(CODE)) + CODE(1:length(CODE-1))) / 2
2086 The optimized values are returned as TABLE and CODE. In addition
2087 the distortion of the the optimized codes representing the
2088 training signal is returned as DIST. The relative distortion in
2089 the final iteration is also returned as RELDIST.
2097 # name: <cell-element>
2101 Optimize the quantization table and codes to reduce distortion.
2105 # name: <cell-element>
2112 # name: <cell-element>
2116 -- Function File: M = lz77deco (C, ALPH, LA, N)
2117 Lempel-Ziv 77 source algorithm decoding implementation. Where
2120 message decoded (1xN).
2123 encoded message (Mx3).
2129 lookahead buffer size.
2132 sliding window buffer size.
2140 # name: <cell-element>
2144 Lempel-Ziv 77 source algorithm decoding implementation.
2148 # name: <cell-element>
2155 # name: <cell-element>
2159 -- Function File: C = lz77enco (M, ALPH, LA, N)
2160 Lempel-Ziv 77 source algorithm implementation. Where
2163 encoded message (Mx3).
2169 lookahead buffer size.
2172 sliding window buffer size.
2180 # name: <cell-element>
2184 Lempel-Ziv 77 source algorithm implementation.
2188 # name: <cell-element>
2195 # name: <cell-element>
2199 -- Function File: INTRLVD = matdeintrlv (DATA, NROWS, NCOLS)
2200 Restore elements of DATA with a tempory matrix of size
2209 # name: <cell-element>
2213 Restore elements of DATA with a tempory matrix of size NROWS-by-NCOLS.
2217 # name: <cell-element>
2224 # name: <cell-element>
2228 -- Function File: INTRLVD = matintrlv (DATA, NROWS, NCOLS)
2229 Interleaved elements of DATA with a tempory matrix of size
2232 See also: matdeintrlv
2238 # name: <cell-element>
2242 Interleaved elements of DATA with a tempory matrix of size
2247 # name: <cell-element>
2254 # name: <cell-element>
2258 -- Function File: minpol (V)
2259 Finds the minimum polynomial for elements of a Galois Field. For a
2260 vector V with N components, representing N values in a Galois
2261 Field GF(2^M), return the minimum polynomial in GF(2) representing
2267 # name: <cell-element>
2271 Finds the minimum polynomial for elements of a Galois Field.
2275 # name: <cell-element>
2282 # name: <cell-element>
2286 -- Function File: modmap (METHOD,...)
2287 -- Function File: y = modmap (X,FD,FS,'ask',M)
2288 -- Function File: y = modmap (X,FD,FS,'fsk',M,TONE)
2289 -- Function File: y = modmap (X,FD,FS,'msk')
2290 -- Function File: y = modmap (X,FD,FS,'psk',M)
2291 -- Function File: y = modmap (X,FD,FS,'qask',M)
2292 -- Function File: y = modmap (X,FD,FS,'qask/cir',NSIG,AMP,PHS)
2293 -- Function File: y = modmap (X,FD,FS,'qask/arb',INPHASE,QUADR)
2294 -- Function File: y = modmap (X,FD,FS,'qask/arb',MAP)
2295 Mapping of a digital signal to an analog signal. With no output
2296 arguments "modmap" plots the constellation of the mapping. In this
2297 case the first argument must be the string METHOD defining one of
2298 'ask', 'fsk', 'msk', 'qask', 'qask/cir' or 'qask/arb'. The
2299 arguments following the string METHOD are generally the same as
2300 those after the corresponding string in the fucntion call without
2301 output arguments. The exception is `modmap('msk',FD)'.
2303 With an output argument, Y is the complex mapped analog signal. In
2304 this case the arguments X, FD and FS are required. The variable X
2305 is the digital signal to be mapped, FD is the sampling rate of the
2306 of digital signal and the FS is the sampling rate of the analog
2307 signal. It is required that `FS/FD' is an integer.
2309 The available mapping of the digital signal are
2312 Amplitude shift keying
2315 Frequency shift keying
2318 Minimum shift keying
2326 Quadraure amplitude shift keying
2328 In addition the 'qask', 'qsk' and 'qam' method can be modified
2329 with the flags '/cir' or '/arb'. That is 'qask/cir' and
2330 'qask/arb', etc are valid methods and give circular- and
2331 arbitrary-qask mappings respectively.
2333 The additional argument M is the order of the modulation to use.
2334 M must be larger than the largest element of X. The variable TONE
2335 is the FSK tone to use in the modulation.
2337 For 'qask/cir', the additional arguments are the same as for
2338 "apkconst", and you are referred to "apkconst" for the definitions
2339 of the additional variables.
2341 For 'qask/arb', the additional arguments INPHASE and QUADR give
2342 the in-phase and quadrature components of the mapping, in a
2343 similar mapping to the outputs of "qaskenco" with one argument.
2344 Similar MAP represents the in-phase and quadrature components of
2345 the mapping as the real and imaginary parts of the variable MAP.
2347 See also: demodmap, dmodce, amodce, apkconst, qaskenco
2352 # name: <cell-element>
2356 Mapping of a digital signal to an analog signal.
2360 # name: <cell-element>
2367 # name: <cell-element>
2371 -- Function File: D = oct2dec (C)
2372 Convert octal to decimal values.
2374 Each element of the octal matrix C is converted to a decimal value.
2376 See also: base2dec, bin2dec, dec2bin
2382 # name: <cell-element>
2386 Convert octal to decimal values.
2390 # name: <cell-element>
2397 # name: <cell-element>
2401 -- Function File: Y = pamdemod (X, M)
2402 -- Function File: Y = pamdemod (X, M, PHI)
2403 -- Function File: Y = pamdemod (X, M, PHI, TYPE)
2404 Demodulates a pulse amplitude modulated signal X into an
2405 information sequence of integers in the range `[0 ... M-1]'. PHI
2406 controls the initial phase and TYPE controls the constellation
2407 mapping. If TYPE is set to 'Bin' will result in binary encoding,
2408 in contrast, if set to 'Gray' will give Gray encoding. An example
2409 of Gray-encoded 8-PAM is
2411 d = randint(1,1e4,8);
2412 y = pammod(d,8,0,'Gray');
2414 d_est = pamdemod(z,8,0,'Gray');
2423 # name: <cell-element>
2427 Demodulates a pulse amplitude modulated signal X into an information
2432 # name: <cell-element>
2439 # name: <cell-element>
2443 -- Function File: Y = pammod (X, M)
2444 -- Function File: Y = pammod (X, M, PHI)
2445 -- Function File: Y = pammod (X, M, PHI, TYPE)
2446 Modulates an information sequence of integers X in the range `[0
2447 ... M-1]' onto a pulse amplitude modulated signal Y. PHI controls
2448 the initial phase and TYPE controls the constellation mapping. If
2449 TYPE is set to 'Bin' will result in binary encoding, in contrast,
2450 if set to 'Gray' will give Gray encoding. An example of
2451 Gray-encoded 8-PAM is
2453 d = randint(1,1e4,8);
2454 y = pammod(d,8,0,'Gray');
2463 # name: <cell-element>
2467 Modulates an information sequence of integers X in the range `[0 .
2471 # name: <cell-element>
2478 # name: <cell-element>
2482 Implement book keeping for a Pseudo-Random Binary Sequence ( PRBS )
2483 also called as a Linear Feedback Shift Register.
2485 Given a polynomial create a PRBS structure for that polynomial.
2486 Now all we need is to just create this polynomial and make it work.
2487 polynomial must be a vector containing the powers of x and an optional
2488 value 1. eg: x^3 + x^2 + x + 1 must be written as [3 2 1 0]
2489 all the coefficients are either 1 or 0. It generates only a Binary \
2490 sequence, and the generator polynomial need to be only a binary
2491 polynomial in GF(2).
2493 connections, contains a struct of vectors where each vector is the
2494 connection list mapping its vec(2:end) elements to the vec(1) output.
2496 Example: If you had a PRBS shift register like the diagram
2497 below with 4 registers we use representation by polynomial
2498 of [ 1 2 3 4], and feedback connections between [ 1 3 4 ].
2499 The output PRBS sequence is taken from the position 4.
2501 +---+ +----+ +---+ +---+
2502 | D |----| D |---| D |---| D |
2503 +---+ +----+ +---+ +---+
2506 [+]---------------+------+
2507 1 + 0.D + 1.D^2 + 1.D^3
2509 The code to implement this PRBS with a start state of [1 0 1 1]
2512 prbs=prbs_generator([1 3 4],{[1 3 4]},[1 0 1 1]);
2513 x = prbs_sequence(prbs) #gives 15
2515 prbs_iterator( prbs, 15 ) #15 binary digits seen
2516 [ 1 1 0 1 0 1 1 1 1 0 0 0 1 0 0 ]
2518 See Also: This function is to be used along with functions
2519 prbs_iterator, and prbs_sequence.
2523 # name: <cell-element>
2527 Implement book keeping for a Pseudo-Random Binary Sequence ( PRBS )
2532 # name: <cell-element>
2539 # name: <cell-element>
2543 This function generates the output bits from the PRBS
2544 state, for the number of iterations specified.
2546 First argument is the PRBS structure obtained from prbs_generator.
2547 PRBS iterations is specified in the second argument.
2548 PRBS start state is taken from the prbs.sregs.
2550 Second argument of the output is PRBS structure with a new
2551 state. This allows usage like:
2553 [ seq, prbs ] = prbs_iterator( prbs, niterations );
2555 while the state of the PRBS is updated.
2557 Example: If you had a PRBS shift register like the diagram
2558 below with 4 registers we use representation by polynomial
2559 of [ 1 2 3 4], and feedback connections between [ 1 3 4 ].
2560 The output PRBS sequence is taken from the position 4.
2562 +---+ +----+ +---+ +---+
2563 | D |----| D |---| D |---| D |
2564 +---+ +----+ +---+ +---+
2567 [+]---------------+------+
2568 1 + 0.D + 1.D^2 + 1.D^3
2570 The code to implement this PRBS will be
2571 prbs=prbs_generator([1 3 4],{[1 3 4]},[1 0 1 1]);
2572 x = prbs_iterator(prbs,15)
2574 See Also: This function is to be used along with functions
2575 prbs_iterator, prbs_generator and prbs_sequence.
2579 # name: <cell-element>
2583 This function generates the output bits from the PRBS
2584 state, for the number of
2588 # name: <cell-element>
2595 # name: <cell-element>
2599 Implement book keeping for a Pseudo-Random Binary Sequence ( PRBS )
2600 also called as a Linear Feedback Shift Register.
2602 For the given PRBS in a intial state, compute the PRBS sequence length.
2603 Length is period of output when the PRBS state is same as
2604 the start state of PRBS.
2606 Example: If you had a PRBS shift register like the diagram
2607 below with 4 registers we use representation by polynomial
2608 of [ 1 2 3 4], and feedback connections between [ 1 3 4 ].
2609 The output PRBS sequence is taken from the position 4.
2611 +---+ +----+ +---+ +---+
2612 | D |----| D |---| D |---| D |
2613 +---+ +----+ +---+ +---+
2616 [+]---------------+------+
2617 1 + 0.D + 1.D^2 + 1.D^3
2619 The code to implement this PRBS will be
2620 prbs=prbs_generator([1 3 4],{[1 3 4]},[1 0 1 1]);
2621 x = prbs_sequence(prbs) #gives 15
2624 See Also: This function is to be used along with functions
2629 # name: <cell-element>
2633 Implement book keeping for a Pseudo-Random Binary Sequence ( PRBS )
2638 # name: <cell-element>
2645 # name: <cell-element>
2649 -- Function File: Y = pamdemod (X, M)
2650 -- Function File: Y = pamdemod (X, M, PHI)
2651 -- Function File: Y = pamdemod (X, M, PHI, TYPE)
2652 Demodulates a complex-baseband phase shift keying modulated signal
2653 into an information sequence of integers in the range `[0 ...
2654 M-1]'. PHI controls the initial phase and TYPE controls the
2655 constellation mapping. If TYPE is set to 'Bin' will result in
2656 binary encoding, in contrast, if set to 'Gray' will give Gray
2657 encoding. An example of Gray-encoded 8-PSK is
2659 d = randint(1,1e3,8);
2660 y = pskmod(d,8,0,'Gray');
2662 d_est = pskdemod(z,8,0,'Gray');
2671 # name: <cell-element>
2675 Demodulates a complex-baseband phase shift keying modulated signal into
2680 # name: <cell-element>
2687 # name: <cell-element>
2691 -- Function File: Y = pskmod (X, M)
2692 -- Function File: Y = pskmod (X, M, PHI)
2693 -- Function File: Y = pskmod (X, M, PHI, TYPE)
2694 Modulates an information sequence of integers X in the range `[0
2695 ... M-1]' onto a complex baseband phase shift keying modulated
2696 signal Y. PHI controls the initial phase and TYPE controls the
2697 constellation mapping. If TYPE is set to 'Bin' will result in
2698 binary encoding, in contrast, if set to 'Gray' will give Gray
2699 encoding. An example of Gray-encoded QPSK is
2701 d = randint(1,5e3,4);
2702 y = pskmod(d,4,0,'Gray');
2711 # name: <cell-element>
2715 Modulates an information sequence of integers X in the range `[0 .
2719 # name: <cell-element>
2726 # name: <cell-element>
2730 -- Function File: qamdemod (X,M)
2731 Create the QAM demodulation of x with a size of alphabet m.
2733 See also: qammod, pskmod, pskdemod
2739 # name: <cell-element>
2743 Create the QAM demodulation of x with a size of alphabet m.
2747 # name: <cell-element>
2754 # name: <cell-element>
2758 -- Function File: qammod (X,M)
2759 Create the QAM modulation of x with a size of alphabet m.
2761 See also: qamdemod, pskmod, pskdemod
2767 # name: <cell-element>
2771 Create the QAM modulation of x with a size of alphabet m.
2775 # name: <cell-element>
2782 # name: <cell-element>
2786 -- Function File: MSG = qaskdeco (C,M)
2787 -- Function File: MSG = qaskdeco (INPHASE,QUADR,M)
2788 -- Function File: MSG = qaskdeco (...,MNMX)
2789 Demaps an analog signal using a square QASK constellation. The
2790 input signal maybe either a complex variable C, or as two real
2791 variables INPHASE and QUADR representing the in-phase and
2792 quadrature components of the signal.
2794 The argument M must be a positive integer power of 2. By deafult
2795 the same constellation as created in "qaskenco" is used by
2796 "qaskdeco". If is possible to change the values of the minimum
2797 and maximum of the in-phase and quadrature components of the
2798 constellation to account for linear changes in the signal values
2799 in the received signal. The variable MNMX is a 2-by-2 matrix of
2802 | min in-phase , max in-phase |
2803 | min quadrature , max quadrature |
2805 If `sqrt(M)' is an integer, then "qaskenco" uses a Gray mapping.
2806 Otherwise, an attempt is made to create a nearly square mapping
2807 with a minimum Hamming distance between adjacent constellation
2815 # name: <cell-element>
2819 Demaps an analog signal using a square QASK constellation.
2823 # name: <cell-element>
2830 # name: <cell-element>
2834 -- Function File: qaskenco (M)
2835 -- Function File: qaskenco (MSG,M)
2836 -- Function File: Y = qaskenco (...)
2837 -- Function File: [INPHASE, QUADR] = qaskenco (...)
2838 Map a digital signal using a square QASK constellation. The
2839 argument M must be a positive integer power of 2. With two input
2840 arguments the variable MSG represents the message to be encoded.
2841 The values of MSG must be between 0 and `M-1'. In all cases
2842 `qaskenco(M)' is equivalent to `qaskenco(1:M,M)'
2844 Three types of outputs can be created depending on the number of
2845 output arguments. That is
2848 In this case "qaskenco" plots the constellation. Only the
2849 points in MSG are plotted, which in the case of a single input
2850 argument is all constellation points.
2852 A single output argument
2853 The returned variable is a complex variable representing the
2854 in-phase and quadrature components of the mapped message
2855 MSG. With, a single input argument this effectively gives the
2856 mapping from symbols to constellation points
2858 Two output arguments
2859 This is the same as two ouput arguments, expect that the
2860 in-phase and quadrature components are returned explicitly.
2863 octave> c = qaskenco(msg, m);
2864 octave> [a, b] = qaskenco(msg, m);
2865 octave> all(c == a + 1i*b)
2868 If `sqrt(M)' is an integer, then "qaskenco" uses a Gray mapping.
2869 Otherwise, an attempt is made to create a nearly square mapping
2870 with a minimum Hamming distance between adjacent constellation
2878 # name: <cell-element>
2882 Map a digital signal using a square QASK constellation.
2886 # name: <cell-element>
2893 # name: <cell-element>
2897 -- Function File: [Y] = qfunc (X)
2898 Compute the Q function.
2906 # name: <cell-element>
2910 Compute the Q function.
2914 # name: <cell-element>
2921 # name: <cell-element>
2925 -- Function File: [Y] = qfuncinv (X)
2926 Compute the inverse Q function.
2934 # name: <cell-element>
2938 Compute the inverse Q function.
2942 # name: <cell-element>
2949 # name: <cell-element>
2953 -- Function File: QIDX = quantiz (X, TABLE)
2954 -- Function File: [QIDX, Q] = quantiz (X, TABLE, CODES)
2955 -- Function File: [ QIDX, Q, D] = quantiz (...)
2956 Quantization of an arbitrary signal relative to a paritioning.
2958 `qidx = quantiz(x, table)'
2959 Determine position of x in strictly monotonic table. The
2960 first interval, using index 0, corresponds to x <= table(1).
2961 Subsequent intervals are table(i-1) < x <= table(i).
2963 `[qidx, q] = quantiz(x, table, codes)'
2964 Associate each interval of the table with a code. Use
2965 codes(1) for x <= table(1) and codes(n+1) for table(n) < x
2968 `[qidx, q, d] = quantiz(...)'
2969 Compute distortion as mean squared distance of x from the
2970 corresponding quantization values.
2975 # name: <cell-element>
2979 Quantization of an arbitrary signal relative to a paritioning.
2983 # name: <cell-element>
2990 # name: <cell-element>
2994 -- Function File: INTRLVD = randdeintrlv (DATA, STATE)
2995 Restore elements of DATA with a random permutation.
2997 See also: randintrlv, intrlv, deintrlv
3003 # name: <cell-element>
3007 Restore elements of DATA with a random permutation.
3011 # name: <cell-element>
3018 # name: <cell-element>
3022 -- Function File: B = randerr (N)
3023 -- Function File: B = randerr (N,M)
3024 -- Function File: B = randerr (N,M,ERR)
3025 -- Function File: B = randerr (N,M,ERR,SEED)
3026 Generate a matrix of random bit errors. The size of the matrix is
3027 N rows by M columns. By default M is equal to N. Bit errors in
3028 the matrix are indicated by a 1.
3030 The variable ERR determines the number of errors per row. By
3031 default the return matrix B has exactly one bit error per row. If
3032 ERR is a scalar, there each row of B has exactly this number of
3033 errors per row. If ERR is a vector then each row has a number of
3034 errors that is in this vector. Each number of errors has an equal
3035 probability. If ERR is a matrix with two rows, then the first row
3036 determines the number of errors and the second their probabilities.
3038 The variable SEED allows the random number generator to be seeded
3039 with a fixed value. The initial seed will be restored when
3045 # name: <cell-element>
3049 Generate a matrix of random bit errors.
3053 # name: <cell-element>
3060 # name: <cell-element>
3064 -- Function File: B = randint (N)
3065 -- Function File: B = randint (N,M)
3066 -- Function File: B = randint (N,M,RANGE)
3067 -- Function File: B = randint (N,M,RANGE,SEED)
3068 Generate a matrix of random binary numbers. The size of the matrix
3069 is N rows by M columns. By default M is equal to N.
3071 The range in which the integers are generated will is determined by
3072 the variable RANGE. If RANGE is an integer, the value will lie in
3073 the range [0,RANGE-1], or [RANGE+1,0] if RANGE is negative. If
3074 RANGE contains two elements the intgers will lie within these two
3075 elements, inclusive. By default RANGE is assumed to be [0:1].
3077 The variable SEED allows the random number generator to be seeded
3078 with a fixed value. The initial seed will be restored when
3084 # name: <cell-element>
3088 Generate a matrix of random binary numbers.
3092 # name: <cell-element>
3099 # name: <cell-element>
3103 -- Function File: INTRLVD = randintrlv (DATA, STATE)
3104 Interleaves elements of DATA with a random permutation.
3106 See also: intrlv, deintrlv
3112 # name: <cell-element>
3116 Interleaves elements of DATA with a random permutation.
3120 # name: <cell-element>
3127 # name: <cell-element>
3131 -- Function File: B = randsrc (N)
3132 -- Function File: B = randsrc (N,M)
3133 -- Function File: B = randsrc (N,M,ALPHABET)
3134 -- Function File: B = randsrc (N,M,ALPHABET,SEED)
3135 Generate a matrix of random symbols. The size of the matrix is N
3136 rows by M columns. By default M is equal to N.
3138 The variable ALPHABET can be either a row vector or a matrix with
3139 two rows. When ALPHABET is a row vector the symbols returned in B
3140 are chosen with equal probability from ALPHABET. When ALPHABET has
3141 two rows, the second row determines the probabilty with which each
3142 of the symbols is chosen. The sum of the probabilities must equal
3143 1. By default ALPHABET is [-1 1].
3145 The variable SEED allows the random number generator to be seeded
3146 with a fixed value. The initial seed will be restored when
3152 # name: <cell-element>
3156 Generate a matrix of random symbols.
3160 # name: <cell-element>
3167 # name: <cell-element>
3171 -- Function File: reedmullerdec (VV,G,R,M)
3172 Decode the received code word VV using the RM-generator matrix G,
3173 of order R, M, returning the code-word C. We use the standard
3174 majority logic vote method due to Irving S. Reed. The received
3175 word has to be a matrix of column size equal to to code-word size
3176 (i.e 2^m). Each row is treated as a separate received word.
3178 The second return value is the message M got from C.
3180 G is obtained from definition type construction of Reed Muller
3181 code, of order R, length 2^M. Use the function reedmullergen, for
3182 the generator matrix for the (R,M) order RM code.
3184 Faster code constructions (also easier) exist, but since finding
3185 permutation order of the basis vectors, is important, we stick
3186 with the standard definitions. To use decoder function
3187 reedmullerdec, you need to use this specific generator function.
3189 see: Lin & Costello, Ch.4, "Error Control Coding", 2nd Ed, Pearson.
3191 G=reedmullergen(2,4);
3194 [dec_C,dec_M]=reedmullerdec(C,G,2,4)
3197 See also: reedmullergen, reedmullerenc
3202 # name: <cell-element>
3206 Decode the received code word VV using the RM-generator matrix G, of
3211 # name: <cell-element>
3218 # name: <cell-element>
3222 -- Function File: reedmullerenc (MSG,R,M)
3223 Definition type construction of Reed Muller code, of order R,
3224 length 2^M. This function returns the generator matrix for the
3227 Encodes the given message word/block, of column size k,
3228 corresponding to the RM(R,M), and outputs a code matrix C, on each
3229 row with corresponding codeword. The second return value is the
3230 G, which is generator matrix used for this code.
3232 MSG=[rand(10,11)>0.5];
3233 [C,G]=reedmullerenc(MSG,2,4);
3236 See also: reedmullerdec, reedmullergen
3241 # name: <cell-element>
3245 Definition type construction of Reed Muller code, of order R, length
3250 # name: <cell-element>
3257 # name: <cell-element>
3261 -- Function File: reedmullergen (R,M)
3262 Definition type construction of Reed Muller code, of order R,
3263 length 2^M. This function returns the generator matrix for the
3266 RM(r,m) codes are characterized by codewords, `sum ( (m,0) + (m,1)
3267 + ... + (m,r)'. Each of the codeword is got through spanning the
3268 space, using the finite set of m-basis codewords. Each codeword
3269 is 2^M elements long. see: Lin & Costello, "Error Control
3272 Faster code constructions (also easier) exist, but since finding
3273 permutation order of the basis vectors, is important, we stick
3274 with the standard definitions. To use decoder function
3275 reedmullerdec, you need to use this specific generator function.
3277 G=reedmullergen(2,4);
3280 See also: reedmullerdec, reedmullerenc
3285 # name: <cell-element>
3289 Definition type construction of Reed Muller code, of order R, length
3294 # name: <cell-element>
3301 # name: <cell-element>
3305 -- Function File: ricedeco (CODE, K)
3306 Returns the Rice decoded signal vector using CODE and K.
3307 Compulsory K is need to be specified. A restrictions is that a
3308 signal set must strictly be non-negative. The value of code is a
3309 cell array of row-vectors which have the encoded rice value for a
3310 single sample. The Rice algorithm is used to encode the 'code'
3311 and only that can be meaningfully decoded. CODE is assumed to have
3312 been of format generated by the function `riceenco'.
3314 Reference: Solomon Golomb, Run length Encodings, 1966 IEEE Trans
3317 An exmaple of the use of `ricedeco' is
3318 ricedec(riceenco(1:4,2),2)
3325 # name: <cell-element>
3329 Returns the Rice decoded signal vector using CODE and K.
3333 # name: <cell-element>
3340 # name: <cell-element>
3344 -- Function File: riceenco (SIG, K)
3345 Returns the Rice encoded signal using K or optimal K . Default
3346 optimal K is chosen between 0-7. Currently no other way to
3347 increase the range except to specify explicitly. Also returns K
3348 parameter used (in case it were to be chosen optimally) and LTOT
3349 the total length of output code in bits. This function uses a K
3350 if supplied or by default chooses the optimal K for encoding
3351 signal vector into a rice coded vector. A restrictions is that a
3352 signal set must strictly be non-negative. The Rice algorithm is
3353 used to encode the data into unary coded quotient part which is
3354 represented as a set of 1's separated from the K-part (binary)
3355 using a zero. This scheme doesnt need any kind of dictionaries and
3356 its close to O(N), but this implementation *may be* sluggish,
3359 Reference: Solomon Golomb, Run length Encodings, 1966 IEEE Trans
3362 An exmaple of the use of `riceenco' is
3371 # name: <cell-element>
3375 Returns the Rice encoded signal using K or optimal K .
3379 # name: <cell-element>
3386 # name: <cell-element>
3390 -- Function File: rledeco (MESSAGE)
3391 Returns decoded run-length MESSAGE. The RLE encoded MESSAGE has
3392 to be in the form of a row-vector. The message format (encoded
3393 RLE) is like repetition [factor, value]+.
3395 An example use of `rledeco' is
3396 message=[1 5 2 4 3 1];
3397 rledeco(message) #gives
3398 ans = [ 5 4 4 1 1 1]
3405 # name: <cell-element>
3409 Returns decoded run-length MESSAGE.
3413 # name: <cell-element>
3420 # name: <cell-element>
3424 -- Function File: rleenco (MESSAGE)
3425 Returns run-length encoded MESSAGE. The rle form is built from
3426 MESSAGE. The original MESSAGE has to be in the form of a
3427 row-vector. The encoded MESSAGE format (encoded RLE) is like
3428 [repetition factor]+, values.
3430 An example use of `rleenco' is
3431 message=[ 5 4 4 1 1 1]
3432 rleenco(message) #gives
3433 ans = [1 5 2 4 3 1];
3440 # name: <cell-element>
3444 Returns run-length encoded MESSAGE.
3448 # name: <cell-element>
3455 # name: <cell-element>
3459 -- Function File: rsdecof (IN,OUT)
3460 -- Function File: rsdecof (IN,OUT,T)
3461 Decodes an ascii file using a Reed-Solomon coder. The input file is
3462 defined by IN and the result is written to the output file OUT.
3463 The type of coding to use is determined by whether the input file
3464 is 7- or 8-bit. If the input file is 7-bit, the default coding is
3465 [127,117]. while the default coding for an 8-bit file is a [255,
3466 235]. This allows for 5 or 10 error characters in 127 or 255
3467 symbols to be corrected respectively. The number of errors that
3468 can be corrected can be overridden by the variable T.
3470 If the file is not an integer multiple of the message size (127 or
3471 255) in length, then the file is padded with the EOT (ascii
3472 character 4) character before decoding.
3480 # name: <cell-element>
3484 Decodes an ascii file using a Reed-Solomon coder.
3488 # name: <cell-element>
3495 # name: <cell-element>
3499 -- Function File: rsencof (IN,OUT)
3500 -- Function File: rsencof (IN,OUT,T)
3501 -- Function File: rsencof (...,PAD)
3502 Encodes an ascii file using a Reed-Solomon coder. The input file is
3503 defined by IN and the result is written to the output file OUT.
3504 The type of coding to use is determined by whether the input file
3505 is 7- or 8-bit. If the input file is 7-bit, the default coding is
3506 [127,117]. while the default coding for an 8-bit file is a [255,
3507 235]. This allows for 5 or 10 error characters in 127 or 255
3508 symbols to be corrected respectively. The number of errors that
3509 can be corrected can be overridden by the variable T.
3511 If the file is not an integer multiple of the message size (127 or
3512 255) in length, then the file is padded with the EOT (ascii
3513 character 4) characters before coding. Whether these characters
3514 are written to the output is defined by the PAD variable. Valid
3515 values for PAD are "pad" (the default) and "nopad", which write or
3516 not the padding respectively.
3524 # name: <cell-element>
3528 Encodes an ascii file using a Reed-Solomon coder.
3532 # name: <cell-element>
3539 # name: <cell-element>
3543 -- Function File: G = rsgenpoly (N,K)
3544 -- Function File: G = rsgenpoly (N,K,P)
3545 -- Function File: G = rsgenpoly (N,K,P,B,S)
3546 -- Function File: G = rsgenpoly (N,K,P,B)
3547 -- Function File: [G, T] = rsgenpoly (...)
3548 Creates a generator polynomial for a Reed-Solomon coding with
3549 message length of K and codelength of N. N must be greater than K
3550 and their difference must be even. The generator polynomial is
3551 returned on G as a polynomial over the Galois Field GF(2^M) where
3552 N is equal to `2^M-1'. If M is not integer the next highest
3553 integer value is used and a generator for a shorten Reed-Solomon
3556 The elements of G represent the coefficients of the polynomial in
3557 descending order. If the length of G is lg, then the generator
3558 polynomial is given by
3560 G(0) * x^(lg-1) + G(1) * x^(lg-2) + ... + G(lg-1) * x + G(lg).
3562 If P is defined then it is used as the primitive polynomial of the
3563 the Galois Field GF(2^M). The default primitive polynomial will be
3564 used if P is equal to [].
3566 The variables B and S determine the form of the generator
3567 polynomial in the following manner.
3569 G = (X - A^(B*S)) * (X - A^((B+1)*S)) * ... * (X - A^((B+2*T-1)*S)).
3571 where T is `(N-K)/2', and A is the primitive element of the Galois
3572 Field. Therefore B is the first consecutive root of the generator
3573 polynomial and S is the primitive element to generate the the
3576 If requested the variable T, which gives the error correction
3577 capability of the the Reed-Solomon code
3579 See also: gf, rsenc, rsdec
3584 # name: <cell-element>
3588 Creates a generator polynomial for a Reed-Solomon coding with message
3593 # name: <cell-element>
3600 # name: <cell-element>
3604 -- Function File: scatterplot (X)
3605 -- Function File: scatterplot (X,N)
3606 -- Function File: scatterplot (X,N,OFF)
3607 -- Function File: scatterplot (X,N,OFF,STR)
3608 -- Function File: scatterplot (X,N,OFF,STR,H)
3609 -- Function File: H = scatterplot (...)
3610 Display the scatter plot of a signal. The signal X can be either in
3614 In this case the signal is assumed to be real and represented
3615 by the vector X. The scatterplot is plotted along the x axis
3619 In this case the in-phase and quadrature components of the
3620 signal are plotted seperately on the x and y axes
3623 A matrix with two columns
3624 In this case the first column represents the in-phase and the
3625 second the quadrature components of a complex signal and are
3626 plotted on the x and y axes respectively.
3628 Each point of the scatter plot is assumed to be seperated by N
3629 elements in the signal. The first element of the signal to plot is
3630 determined by OFF. By default N is 1 and OFF is 0.
3632 The string STR is a plot style string (example 'r+'), and by
3633 default is the default gnuplot point style.
3635 The figure handle to use can be defined by H. If H is not given,
3636 then the next available figure handle is used. The figure handle
3637 used in returned on HOUT.
3639 See also: eyediagram
3644 # name: <cell-element>
3648 Display the scatter plot of a signal.
3652 # name: <cell-element>
3659 # name: <cell-element>
3663 -- Function File: shannonfanodeco (HCODE,DICT)
3664 Returns the original signal that was Shannonfano encoded. The
3665 signal was encoded using `shannonfanoenco'. This function uses a
3666 dict built from the `shannonfanodict' and uses it to decode a
3667 signal list into a shannonfano list. Restrictions include hcode is
3668 expected to be a binary code; returned signal set that strictly
3669 belongs in the `range [1,N]', with `N=length(dict)'. Also dict can
3670 only be from the `shannonfanodict(...)' routine. Whenever decoding
3671 fails, those signal values are indicated by -1, and we successively
3672 try to restart decoding from the next bit that hasnt failed in
3673 decoding, ad-infinitum.
3675 An example use of `shannonfanodeco' is
3676 hd=shannonfanodict(1:4,[0.5 0.25 0.15 0.10])
3677 hcode=shannonfanoenco(1:4,hd) # [ 1 0 1 0 0 0 0 0 1 ]
3678 shannonfanodeco(hcode,hd) # [1 2 3 4]
3680 See also: shannonfanoenco, shannonfanodict
3685 # name: <cell-element>
3689 Returns the original signal that was Shannonfano encoded.
3693 # name: <cell-element>
3700 # name: <cell-element>
3704 -- Function File: shannonfanodict (SYMBOLS,SYMBOL_PROBABILITES)
3705 Returns the code dictionary for source using shanno fano algorithm.
3706 Dictionary is built from SYMBOL_PROBABILITIES using the shannon
3707 fano scheme. Output is a dictionary cell-array, which are
3708 codewords, and correspond to the order of input probability.
3710 CW=shannonfanodict(1:4,[0.5 0.25 0.15 0.1]);
3711 assert(redundancy(CW,[0.5 0.25 0.15 0.1]),0.25841,0.001)
3712 shannonfanodict(1:5,[0.35 0.17 0.17 0.16 0.15])
3713 shannonfanodict(1:8,[8 7 6 5 5 4 3 2]./40)
3715 See also: shannonfanoenc, shannonfanodec
3720 # name: <cell-element>
3724 Returns the code dictionary for source using shanno fano algorithm.
3728 # name: <cell-element>
3735 # name: <cell-element>
3739 -- Function File: shannonfanoenco (HCODE,DICT)
3740 Returns the Shannon Fano encoded signal using DICT. This function
3741 uses a DICT built from the `shannonfanodict' and uses it to encode
3742 a signal list into a shannon fano code. Restrictions include a
3743 signal set that strictly belongs in the `range [1,N]' with
3744 `N=length(dict)'. Also dict can only be from the
3745 `shannonfanodict()' routine. An example use of `shannonfanoenco'
3748 hd=shannonfanodict(1:4,[0.5 0.25 0.15 0.10])
3749 shannonfanoenco(1:4,hd) # [ 0 1 0 1 1 0 1 1 1 0]
3751 See also: shannonfanodeco, shannonfanodict
3756 # name: <cell-element>
3760 Returns the Shannon Fano encoded signal using DICT.
3764 # name: <cell-element>
3771 # name: <cell-element>
3775 -- Function File: [NUM, RATE] = symerr (A,B)
3776 -- Function File: [NUM, RATE] = symerr (...,FLAG)
3777 -- Function File: [NUM, RATE IND] = symerr (...)
3778 Compares two matrices and returns the number of symbol errors and
3779 the symbol error rate. The variables A and B can be either:
3782 In this case both matrices must be the same size and then by
3783 default the the return values NUM and RATE are the overall
3784 number of symbol errors and the overall symbol error rate.
3787 In this case the column vector is used for symbol error
3788 comparision column-wise with the matrix. The returned values
3789 NUM and RATE are then row vectors containing the num of
3790 symbol errors and the symbol error rate for each of the
3791 column-wise comparisons. The number of rows in the matrix
3792 must be the same as the length of the column vector
3795 In this case the row vector is used for symbol error
3796 comparision row-wise with the matrix. The returned values NUM
3797 and RATE are then column vectors containing the num of symbol
3798 errors and the symbol error rate for each of the row-wise
3799 comparisons. The number of columns in the matrix must be the
3800 same as the length of the row vector
3802 This behaviour can be overridden with the variable FLAG. FLAG can
3803 take the value 'column-wise', 'row-wise' or 'overall'. A
3804 column-wise comparision is not possible with a row vector and
3810 # name: <cell-element>
3814 Compares two matrices and returns the number of symbol errors and the
3819 # name: <cell-element>
3826 # name: <cell-element>
3830 -- Function File: systematize (G)
3831 Given G, extract P partiy check matrix. Assume row-operations in
3832 GF(2). G is of size KxN, when decomposed through row-operations
3833 into a I of size KxK identity matrix, and a parity check matrix P
3836 Most arbitrary code with a given generator matrix G, can be
3837 converted into its systematic form using this function.
3839 This function returns 2 values, first is default being GX the
3840 systematic version of the G matrix, and then the parity check
3843 G=[1 1 1 1; 1 1 0 1; 1 0 0 1];
3844 [Gx,P]=systematize(G);
3846 Gx = [1 0 0 1; 0 1 0 0; 0 0 1 0];
3850 See also: bchpoly, biterr
3855 # name: <cell-element>
3859 Given G, extract P partiy check matrix.
3863 # name: <cell-element>
3870 # name: <cell-element>
3874 -- Function File: M = vec2mat (V, C)
3875 -- Function File: M = vec2mat (V, C, D)
3876 -- Function File: [M, ADD] = vec2mat (...)
3877 Converts the vector V into a C column matrix with row priority
3878 arrangement and with the final column padded with the value D to
3879 the correct length. By default D is 0. The amount of padding added
3880 to the matrix is returned in ADD.
3885 # name: <cell-element>
3889 Converts the vector V into a C column matrix with row priority
3894 # name: <cell-element>
3901 # name: <cell-element>
3905 -- Function File: Y = wgn (M,N,P)
3906 -- Function File: Y = wgn (M,N,P,IMP)
3907 -- Function File: Y = wgn (M,N,P,IMP,SEED,)
3908 -- Function File: Y = wgn (...,'TYPE')
3909 -- Function File: Y = wgn (...,'OUTPUT')
3910 Returns a M-by-N matrix Y of white Gaussian noise. P specifies the
3911 power of the output noise, which is assumed to be referenced to an
3912 impedance of 1 Ohm, unless IMP explicitly defines the impedance.
3914 If SEED is defined then the randn function is seeded with this
3917 The arguments TYPE and OUTPUT must follow the above numerial
3918 arguments, but can be specified in any order. TYPE specifies the
3919 units of P, and can be 'dB', 'dBW', 'dBm' or 'linear'. 'dB' is in
3920 fact the same as 'dBW' and is keep as a misnomer of Matlab. The
3921 units of 'linear' are in Watts.
3923 The OUTPUT variable should be either 'real' or 'complex'. If the
3924 output is complex then the power P is divided equally betwen the
3925 real and imaginary parts.
3927 See also: randn, awgn
3933 # name: <cell-element>
3937 Returns a M-by-N matrix Y of white Gaussian noise.