From: <jo...@us...> - 2012-05-11 18:10:38
|
Revision: 10413 http://octave.svn.sourceforge.net/octave/?rev=10413&view=rev Author: jordigh Date: 2012-05-11 18:10:27 +0000 (Fri, 11 May 2012) Log Message: ----------- Fix whitespace in m-files Modified Paths: -------------- trunk/octave-forge/main/comm/inst/ademodce.m trunk/octave-forge/main/comm/inst/amdemod.m trunk/octave-forge/main/comm/inst/ammod.m trunk/octave-forge/main/comm/inst/amodce.m trunk/octave-forge/main/comm/inst/apkconst.m trunk/octave-forge/main/comm/inst/awgn.m trunk/octave-forge/main/comm/inst/bchpoly.m trunk/octave-forge/main/comm/inst/bi2de.m trunk/octave-forge/main/comm/inst/biterr.m trunk/octave-forge/main/comm/inst/compand.m trunk/octave-forge/main/comm/inst/convenc.m trunk/octave-forge/main/comm/inst/de2bi.m trunk/octave-forge/main/comm/inst/decode.m trunk/octave-forge/main/comm/inst/demodmap.m trunk/octave-forge/main/comm/inst/egolaydec.m trunk/octave-forge/main/comm/inst/egolayenc.m trunk/octave-forge/main/comm/inst/egolaygen.m trunk/octave-forge/main/comm/inst/encode.m trunk/octave-forge/main/comm/inst/eyediagram.m trunk/octave-forge/main/comm/inst/fibodeco.m Modified: trunk/octave-forge/main/comm/inst/ademodce.m =================================================================== --- trunk/octave-forge/main/comm/inst/ademodce.m 2012-05-11 18:08:42 UTC (rev 10412) +++ trunk/octave-forge/main/comm/inst/ademodce.m 2012-05-11 18:10:27 UTC (rev 10413) @@ -133,11 +133,11 @@ y = y - offset; else if (min(size(y)) == 1) - y = y - mean(y); + y = y - mean(y); else - for i=1:size(y,2) - y(:,i) = y(:,i) - mean(y(:,i)); - end + for i=1:size(y,2) + y(:,i) = y(:,i) - mean(y(:,i)); + end endif endif elseif (strcmp(typ,"amdsb-sc")) @@ -178,7 +178,7 @@ y = filter(num,den, y); else for i=1:size(y,2) - y(:,i) = filter(num, den, y(:,i)); + y(:,i) = filter(num, den, y(:,i)); end endif endif Modified: trunk/octave-forge/main/comm/inst/amdemod.m =================================================================== --- trunk/octave-forge/main/comm/inst/amdemod.m 2012-05-11 18:08:42 UTC (rev 10412) +++ trunk/octave-forge/main/comm/inst/amdemod.m 2012-05-11 18:10:27 UTC (rev 10413) @@ -1,4 +1,4 @@ -# Copyright (C) 2007 Sylvain Pelissier <syl...@gm...> +## Copyright (C) 2007 Sylvain Pelissier <syl...@gm...> ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software @@ -21,10 +21,10 @@ ## @end deftypefn function [m] = amdemod(s,fc,fs) - if(nargin ~= 3) - usage("m = amdemod(s,fc,fs)"); - end - t = 0:1./fs:(length(s)-1)./fs; - e = s.*cos(2.*pi.*fc.*t); - [b a] = butter(5,fc.*2./fs); - m = filtfilt(b,a,e).*2; + if(nargin ~= 3) + usage("m = amdemod(s,fc,fs)"); + end + t = 0:1./fs:(length(s)-1)./fs; + e = s.*cos(2.*pi.*fc.*t); + [b a] = butter(5,fc.*2./fs); + m = filtfilt(b,a,e).*2; Modified: trunk/octave-forge/main/comm/inst/ammod.m =================================================================== --- trunk/octave-forge/main/comm/inst/ammod.m 2012-05-11 18:08:42 UTC (rev 10412) +++ trunk/octave-forge/main/comm/inst/ammod.m 2012-05-11 18:10:27 UTC (rev 10413) @@ -21,10 +21,10 @@ function [y] = ammod(x,fc,fs) - if (nargin != 3) + if (nargin != 3) usage ("ammod(x,fs,fc)"); endif - l = length(x); - t=0:1./fs:(l-1)./fs; - y = x.*cos(2.*pi.*fc.*t); + l = length(x); + t=0:1./fs:(l-1)./fs; + y = x.*cos(2.*pi.*fc.*t); Modified: trunk/octave-forge/main/comm/inst/amodce.m =================================================================== --- trunk/octave-forge/main/comm/inst/amodce.m 2012-05-11 18:08:42 UTC (rev 10412) +++ trunk/octave-forge/main/comm/inst/amodce.m 2012-05-11 18:10:27 UTC (rev 10413) @@ -146,7 +146,7 @@ elseif (strcmp(typ,"qam")) if (isreal(x)) if (floor(size(x,2)/2) != (size(x,2)/2)) - error ("amodce: QAM modulation must have an even number of columns for real signals"); + error ("amodce: QAM modulation must have an even number of columns for real signals"); endif y = (x(:,1:2:size(x,2)) + 1i * x(:,2:2:size(x,2))); else @@ -161,7 +161,7 @@ ## As x(t) is discrete and not a function, the only way to perform the ## above integration is with Simpson's rule. Note \Delta T = 2 * pi / Fs. pm = pi / Fs * dev * (cumsum([zeros(1,size(x,2));x(1:size(x,1)-1,:)]) ... - + cumsum(x)); + + cumsum(x)); y = exp(1i * (pm + iphs)); else error ("amodce: unknown modulation specified"); Modified: trunk/octave-forge/main/comm/inst/apkconst.m =================================================================== --- trunk/octave-forge/main/comm/inst/apkconst.m 2012-05-11 18:08:42 UTC (rev 10412) +++ trunk/octave-forge/main/comm/inst/apkconst.m 2012-05-11 18:10:27 UTC (rev 10413) @@ -70,26 +70,26 @@ arg = varargin{i}; if (ischar(arg)) if (strcmp(arg,"n")) - try - text(); - printnums = 1; - catch - printnums = 0; - end + try + text(); + printnums = 1; + catch + printnums = 0; + end else - fmt = arg; + fmt = arg; endif else numargs++; switch (numargs) - case 1, - nsig = arg; - case 2, - amp = arg; - case 3, - phs = arg; - otherwise - error ("apkconst: too many numerical arguments"); + case 1, + nsig = arg; + case 2, + amp = arg; + case 3, + phs = arg; + otherwise + error ("apkconst: too many numerical arguments"); endswitch endif end @@ -121,7 +121,7 @@ error ("apkconst: must have at least one point in ASK radii"); endif y = [y; amp(i) * [cos(2*pi*[0:nsig(i)-1]'/nsig(i) + phs(i)) + ... - 1i*sin(2*pi*[0:nsig(i)-1]'/nsig(i) + phs(i))]]; + 1i*sin(2*pi*[0:nsig(i)-1]'/nsig(i) + phs(i))]]; end if (nargout == 0) @@ -134,7 +134,7 @@ if (printnums) xd = 0.05 * max(real(y)); for i=1:length(y) - text(real(y(i))+xd,imag(y(i)),num2str(i-1)); + text(real(y(i))+xd,imag(y(i)),num2str(i-1)); end endif plot (real(y), imag(y), fmt); Modified: trunk/octave-forge/main/comm/inst/awgn.m =================================================================== --- trunk/octave-forge/main/comm/inst/awgn.m 2012-05-11 18:08:42 UTC (rev 10412) +++ trunk/octave-forge/main/comm/inst/awgn.m 2012-05-11 18:10:27 UTC (rev 10413) @@ -77,12 +77,12 @@ else narg++; switch (narg) - case 1, - p = arg; - case 2, - seed = arg; - otherwise - error ("wgn: too many arguments"); + case 1, + p = arg; + case 2, + seed = arg; + otherwise + error ("wgn: too many arguments"); endswitch endif end @@ -93,7 +93,7 @@ if (!isempty(seed)) if (!isscalar(seed) || !isreal(seed) || (seed < 0) || - ((seed-floor(seed)) != 0)) + ((seed-floor(seed)) != 0)) error ("awgn: random seed must be integer"); endif endif @@ -128,20 +128,20 @@ else np = p - snr; endif - + y = x + wgn (m, n, np, 1, seed, type, out); endfunction -%!shared x, y, noisy -%! x = [0:0.01:2*pi]; y = sin (x); -%! noisy = awgn (y, 20, "dB", "measured"); + %!shared x, y, noisy + %! x = [0:0.01:2*pi]; y = sin (x); + %! noisy = awgn (y, 20, "dB", "measured"); ## Test of noisy is pretty arbitrary, but should pickup most errors -%!error awgn (); -%!error awgn (1); -%!error awgn (1,1,1,1,1); -%!assert (isreal(noisy)); -%!assert (iscomplex(awgn(y+1i,20,"dB","measured"))); -%!assert (size(y) == size(noisy)) -%!assert (abs(10*log10(mean(y.^2)/mean((y-noisy).^ 2)) - 20) < 1); + %!error awgn (); + %!error awgn (1); + %!error awgn (1,1,1,1,1); + %!assert (isreal(noisy)); + %!assert (iscomplex(awgn(y+1i,20,"dB","measured"))); + %!assert (size(y) == size(noisy)) + %!assert (abs(10*log10(mean(y.^2)/mean((y-noisy).^ 2)) - 20) < 1); Modified: trunk/octave-forge/main/comm/inst/bchpoly.m =================================================================== --- trunk/octave-forge/main/comm/inst/bchpoly.m 2012-05-11 18:08:42 UTC (rev 10412) +++ trunk/octave-forge/main/comm/inst/bchpoly.m 2012-05-11 18:10:27 UTC (rev 10413) @@ -112,19 +112,19 @@ if (ischar(arg)) probe = 1; if (nargout > 1) - error ("bchpoly: only one output argument allowed when probing valid codes"); + error ("bchpoly: only one output argument allowed when probing valid codes"); endif else if (prim != 0) - error ("bchpoly: primitive polynomial already defined"); + error ("bchpoly: primitive polynomial already defined"); endif prim = arg; if (!isscalar(prim)) - prim = bi2de(prim); + prim = bi2de(prim); endif if ((floor(prim) != prim) || (prim < 2^m) || (prim > 2^(m+1)) || ... - !isprimitive(prim)) - error ("bchpoly: prim must be a primitive polynomial of GF(2^m)"); + !isprimitive(prim)) + error ("bchpoly: prim must be a primitive polynomial of GF(2^m)"); endif endif end @@ -143,29 +143,29 @@ f = []; for t=1:floor(n(ni)/2) - for i=1:nc - if (fc(i) != 1) - cl = log(c{i}); - for j=2*(t-1)+1:2*t - if (find(cl == j)) - f = [f, c{i}.x]; - fc(i) = 1; - break; + for i=1:nc + if (fc(i) != 1) + cl = log(c{i}); + for j=2*(t-1)+1:2*t + if (find(cl == j)) + f = [f, c{i}.x]; + fc(i) = 1; + break; + endif + end + endif + end + + k = nn(ni) - length(f); + if (k < 2) + break; endif - end - endif - end - k = nn(ni) - length(f); - if (k < 2) - break; - endif - - if (!isempty(p) && (k == p(size(p,1),2))) - p(size(p,1),:) = [nn(ni), k, t]; - else - p = [p; [nn(ni), k, t]]; - endif + if (!isempty(p) && (k == p(size(p,1),2))) + p(size(p,1),:) = [nn(ni), k, t]; + else + p = [p; [nn(ni), k, t]]; + endif end end else @@ -181,22 +181,22 @@ t++; f0 = f1; for i=1:nc - if (fc(i) != 1) - cl = log(c{i}); - for j=2*(t-1)+1:2*t - if (find(cl == j)) - f1 = [f1, c{i}.x]; - fc(i) = 1; - ptmp = gf([c{i}(1), 1], m, prim); - for l=2:length(c{i}) - ptmp = conv(ptmp, [c{i}(l), 1]); - end - f = [f; [ptmp.x, zeros(1,m-length(ptmp)+1)]]; - fl = fl + length(ptmp); - break; - endif - end - endif + if (fc(i) != 1) + cl = log(c{i}); + for j=2*(t-1)+1:2*t + if (find(cl == j)) + f1 = [f1, c{i}.x]; + fc(i) = 1; + ptmp = gf([c{i}(1), 1], m, prim); + for l=2:length(c{i}) + ptmp = conv(ptmp, [c{i}(l), 1]); + end + f = [f; [ptmp.x, zeros(1,m-length(ptmp)+1)]]; + fl = fl + length(ptmp); + break; + endif + end + endif end until (length(f1) > nn - k) t--; @@ -216,17 +216,17 @@ p = gf([f0(1), 1], m, prim); for i=2:length(f0) - p = conv(p, [f0(i), 1]); + p = conv(p, [f0(i), 1]); end p = p.x; if (nargout > 3) - if (n > 64) - warning("bchpoly: can not create parity matrix\n"); - par = []; - else - par = cyclgen(n,p); - endif + if (n > 64) + warning("bchpoly: can not create parity matrix\n"); + par = []; + else + par = cyclgen(n,p); + endif endif endif endif Modified: trunk/octave-forge/main/comm/inst/bi2de.m =================================================================== --- trunk/octave-forge/main/comm/inst/bi2de.m 2012-05-11 18:08:42 UTC (rev 10412) +++ trunk/octave-forge/main/comm/inst/bi2de.m 2012-05-11 18:10:27 UTC (rev 10413) @@ -75,22 +75,22 @@ endfunction -%!shared x -%! x = randi ([0 1], 100, 16); -%!assert (bi2de (0), 0) -%!assert (bi2de (1), 1) -%!assert (bi2de (ones (1, 8)), 255) -%!assert (bi2de ([7 7 7 7], 8), 4095) -%!assert (size (bi2de (x)), [100 1]) -%!assert (bi2de (x, "right-msb"), bi2de (x)) -%!assert (bi2de (x, "left-msb"), bi2de (fliplr (x))) + %!shared x + %! x = randi ([0 1], 100, 16); + %!assert (bi2de (0), 0) + %!assert (bi2de (1), 1) + %!assert (bi2de (ones (1, 8)), 255) + %!assert (bi2de ([7 7 7 7], 8), 4095) + %!assert (size (bi2de (x)), [100 1]) + %!assert (bi2de (x, "right-msb"), bi2de (x)) + %!assert (bi2de (x, "left-msb"), bi2de (fliplr (x))) %% Test input validation -%!error bi2de () -%!error bi2de (1, 2, 3, 4) -%!error bi2de (1, 2, 3) -%!error bi2de (1, 2, "invalid") -%!error bi2de (0.1) -%!error bi2de (-1) -%!error bi2de (2) -%!error bi2de (7, 6) + %!error bi2de () + %!error bi2de (1, 2, 3, 4) + %!error bi2de (1, 2, 3) + %!error bi2de (1, 2, "invalid") + %!error bi2de (0.1) + %!error bi2de (-1) + %!error bi2de (2) + %!error bi2de (7, 6) Modified: trunk/octave-forge/main/comm/inst/biterr.m =================================================================== --- trunk/octave-forge/main/comm/inst/biterr.m 2012-05-11 18:08:42 UTC (rev 10412) +++ trunk/octave-forge/main/comm/inst/biterr.m 2012-05-11 18:10:27 UTC (rev 10413) @@ -116,24 +116,24 @@ arg = varargin{i}; if (ischar(arg)) if (strcmp(arg,"row-wise")) - if (strcmp(type,"column")) - error ("biterr: row-wise comparison not possible with column inputs"); - endif - flag = "row"; + if (strcmp(type,"column")) + error ("biterr: row-wise comparison not possible with column inputs"); + endif + flag = "row"; elseif (strcmp(arg,"column-wise")) - if (strcmp(type,"row")) - error ("biterr: column-wise comparison not possible with row inputs"); - endif - flag = "column"; + if (strcmp(type,"row")) + error ("biterr: column-wise comparison not possible with row inputs"); + endif + flag = "column"; elseif (strcmp(arg,"overall")) - flag = "overall"; + flag = "overall"; else - error ("biterr: unrecognized string argument"); + error ("biterr: unrecognized string argument"); endif else k = arg; if (k < m) - error ("biterr: the symbol size is too small for largest element"); + error ("biterr: the symbol size is too small for largest element"); endif endif end @@ -148,16 +148,16 @@ switch (flag) case 'row', if (strcmp(type,"matrix") && (ac == 1)) - num = ind; + num = ind; else num = sum(ind')'; endif rate = num / k / max(ac,bc); case 'column', if (strcmp(type,"matrix") && (ar == 1)) - num = ind; + num = ind; else - num = sum(ind); + num = sum(ind); endif rate = num / k / max(ar,br); case 'overall', Modified: trunk/octave-forge/main/comm/inst/compand.m =================================================================== --- trunk/octave-forge/main/comm/inst/compand.m 2012-05-11 18:08:42 UTC (rev 10412) +++ trunk/octave-forge/main/comm/inst/compand.m 2012-05-11 18:10:27 UTC (rev 10413) @@ -113,4 +113,4 @@ endif endfunction - + Modified: trunk/octave-forge/main/comm/inst/convenc.m =================================================================== --- trunk/octave-forge/main/comm/inst/convenc.m 2012-05-11 18:08:42 UTC (rev 10412) +++ trunk/octave-forge/main/comm/inst/convenc.m 2012-05-11 18:10:27 UTC (rev 10413) @@ -56,10 +56,10 @@ print_usage; endif - # Use conv2 to do repeated 1d convolutions of m with each row of G. - # rem is used to transform the standard convolution result to one - # which uses modulo-2 addition. Only cols with index a mult. of k - # are in the actual enc. output + # Use conv2 to do repeated 1d convolutions of m with each row of G. + # rem is used to transform the standard convolution result to one + # which uses modulo-2 addition. Only cols with index a mult. of k + # are in the actual enc. output x = rem(conv2(1, m(:)', G),2)(:,!rem(1:numel(m),k))(:)'; endfunction Modified: trunk/octave-forge/main/comm/inst/de2bi.m =================================================================== --- trunk/octave-forge/main/comm/inst/de2bi.m 2012-05-11 18:08:42 UTC (rev 10412) +++ trunk/octave-forge/main/comm/inst/de2bi.m 2012-05-11 18:10:27 UTC (rev 10413) @@ -87,21 +87,21 @@ endfunction -%!shared x -%! x = randi ([0 2^16-1], 100, 1); -%!assert (de2bi (0), 0) -%!assert (de2bi (1), 1) -%!assert (de2bi (255), ones (1, 8)) -%!assert (de2bi (255, [], 256), 255) -%!assert (de2bi (1023, 8, 8), [7 7 7 1 0 0 0 0]) -%!assert (size (de2bi (x, 16)), [100 16]) -%!assert (de2bi (x, 16, "right-msb"), de2bi (x, 16)) -%!assert (de2bi (x, 16, "left-msb"), fliplr (de2bi (x, 16))) + %!shared x + %! x = randi ([0 2^16-1], 100, 1); + %!assert (de2bi (0), 0) + %!assert (de2bi (1), 1) + %!assert (de2bi (255), ones (1, 8)) + %!assert (de2bi (255, [], 256), 255) + %!assert (de2bi (1023, 8, 8), [7 7 7 1 0 0 0 0]) + %!assert (size (de2bi (x, 16)), [100 16]) + %!assert (de2bi (x, 16, "right-msb"), de2bi (x, 16)) + %!assert (de2bi (x, 16, "left-msb"), fliplr (de2bi (x, 16))) %% Test input validation -%!error de2bi () -%!error de2bi (1, 2, 3, 4, 5) -%!error de2bi (1, 2, 3, 4) -%!error de2bi (1, 2, 3, "invalid") -%!error de2bi (0.1) -%!error de2bi (-1) + %!error de2bi () + %!error de2bi (1, 2, 3, 4, 5) + %!error de2bi (1, 2, 3, 4) + %!error de2bi (1, 2, 3, "invalid") + %!error de2bi (0.1) + %!error de2bi (-1) Modified: trunk/octave-forge/main/comm/inst/decode.m =================================================================== --- trunk/octave-forge/main/comm/inst/decode.m 2012-05-11 18:08:42 UTC (rev 10412) +++ trunk/octave-forge/main/comm/inst/decode.m 2012-05-11 18:10:27 UTC (rev 10413) @@ -123,31 +123,31 @@ else ## Why the hell did matlab decide on such an ugly way of passing 2 args! if (strcmp(typ,"linear") || strcmp(typ,"linear/binary")) - coding = "linear"; - msgtyp = "binary"; + coding = "linear"; + msgtyp = "binary"; elseif (strcmp(typ,"linear/decimal")) - coding = "linear"; - msgtyp = "decimal"; + coding = "linear"; + msgtyp = "decimal"; elseif (strcmp(typ,"cyclic") || strcmp(typ,"cyclic/binary")) - coding = "cyclic"; - msgtyp = "binary"; + coding = "cyclic"; + msgtyp = "binary"; elseif (strcmp(typ,"cyclic/decimal")) - coding = "cyclic"; - msgtyp = "decimal"; + coding = "cyclic"; + msgtyp = "decimal"; elseif (strcmp(typ,"bch") || strcmp(typ,"bch/binary")) - coding = "bch"; - msgtyp = "binary"; + coding = "bch"; + msgtyp = "binary"; elseif (strcmp(typ,"bch/decimal")) - coding = "bch"; - msgtyp = "decimal"; + coding = "bch"; + msgtyp = "decimal"; elseif (strcmp(typ,"hamming") || strcmp(typ,"hamming/binary")) - coding = "hamming"; - msgtyp = "binary"; + coding = "hamming"; + msgtyp = "binary"; elseif (strcmp(typ,"hamming/decimal")) - coding = "hamming"; - msgtyp = "decimal"; + coding = "hamming"; + msgtyp = "decimal"; else - error ("decode: unrecognized coding and/or message type"); + error ("decode: unrecognized coding and/or message type"); endif endif else @@ -201,50 +201,50 @@ else if (strcmp(coding,"linear")) if (nargin > 4) - gen = opt1; - if ((size(gen,1) != k) || (size(gen,2) != n)) - error ("decode: generator matrix is in incorrect form"); - endif - par = gen2par(gen); - if (nargin > 5) - st = opt2; - else - st = syndtable(par); - endif + gen = opt1; + if ((size(gen,1) != k) || (size(gen,2) != n)) + error ("decode: generator matrix is in incorrect form"); + endif + par = gen2par(gen); + if (nargin > 5) + st = opt2; + else + st = syndtable(par); + endif else - error ("decode: linear coding must supply the generator matrix"); + error ("decode: linear coding must supply the generator matrix"); endif elseif (strcmp(coding,"cyclic")) if (nargin > 4) - [par, gen] = cyclgen(n,opt1); + [par, gen] = cyclgen(n,opt1); else - [par, gen] = cyclgen(n,cyclpoly(n,k)); + [par, gen] = cyclgen(n,cyclpoly(n,k)); endif if (nargin > 5) - ## XXX FIXME XXX Should we check that the generator polynomial is - ## consistent with the syndrome table. Where is the acceleration in - ## this case??? - st = opt2; + ## XXX FIXME XXX Should we check that the generator polynomial is + ## consistent with the syndrome table. Where is the acceleration in + ## this case??? + st = opt2; else - st = syndtable(par); + st = syndtable(par); endif else m = log2(n + 1); if ((m != floor(m)) || (m < 3) || (m > 16)) - error ("decode: codeword length must be of the form '2^m-1' with integer m"); + error ("decode: codeword length must be of the form '2^m-1' with integer m"); endif if (k != (n-m)) - error ("decode: illegal message length for hamming code"); + error ("decode: illegal message length for hamming code"); endif if (nargin > 4) - [par, gen] = hammgen(m, opt1); + [par, gen] = hammgen(m, opt1); else - [par, gen] = hammgen(m); + [par, gen] = hammgen(m); endif if (nargin > 5) - error ("decode: illegal call for hamming coding"); + error ("decode: illegal call for hamming coding"); else - st = syndtable(par); + st = syndtable(par); endif endif Modified: trunk/octave-forge/main/comm/inst/demodmap.m =================================================================== --- trunk/octave-forge/main/comm/inst/demodmap.m 2012-05-11 18:08:42 UTC (rev 10412) +++ trunk/octave-forge/main/comm/inst/demodmap.m 2012-05-11 18:10:27 UTC (rev 10413) @@ -98,13 +98,13 @@ if (nargin > 3) method = varargin{1}; if (!ischar(method) || (!strcmp(method,"ask") && ... - isempty(findstr(method,"msk")) && isempty(findstr(method,"fsk")) && ... - isempty(findstr(method,"samp")) && !strcmp(method,"psk") && ... - !strcmp(method,"qask") && !strcmp(method,"qam") && ... - !strcmp(method,"qsk") && !strcmp(method,"qask/cir") && ... - !strcmp(method,"qam/cir") && !strcmp(method,"qsk/cir") && ... - !strcmp(method,"qask/arb") && !strcmp(method,"qam/arb") && ... - !strcmp(method,"qsk/arb"))) + isempty(findstr(method,"msk")) && isempty(findstr(method,"fsk")) && ... + isempty(findstr(method,"samp")) && !strcmp(method,"psk") && ... + !strcmp(method,"qask") && !strcmp(method,"qam") && ... + !strcmp(method,"qsk") && !strcmp(method,"qask/cir") && ... + !strcmp(method,"qam/cir") && !strcmp(method,"qsk/cir") && ... + !strcmp(method,"qask/arb") && !strcmp(method,"qam/arb") && ... + !strcmp(method,"qsk/arb"))) error ("modmap: unknown mapping method"); endif else @@ -142,24 +142,24 @@ if (!isempty(findstr(method,"fsk")) || !isempty(findstr(method,"msk"))) if (findstr(method,"msk")) if (nargin > 4) - error ("demodmap: too many arguments"); + error ("demodmap: too many arguments"); endif M = 2; tone = fd/2; else if (nargin > 5) - tone = varargin{3}; + tone = varargin{3}; else - tone = fd; + tone = fd; endif if (nargin > 6) - error ("demodmap: too many arguments"); + error ("demodmap: too many arguments"); endif endif if (findstr(method,"/max")) if (size(y,2) != M) - error ("demodmap: when using correlation must have M columns"); + error ("demodmap: when using correlation must have M columns"); endif ## We have an M-column maximum from which with pick index of the maximum ## value in each row as the decoded value @@ -177,37 +177,37 @@ elseif (strcmp(method,"psk")) c = apkconst(M,[],[]); elseif (!isempty(findstr(method,"qask")) || ... - !isempty(findstr(method,"qsk")) || ... - !isempty(findstr(method,"qam"))) + !isempty(findstr(method,"qsk")) || ... + !isempty(findstr(method,"qam"))) if (findstr(method,"/cir")) nsig = 2; amp = []; phs = []; if (nargin > 4) - nsig = varargin{2}; - if (!isvector(nsig)) - error ("modmap: invalid number of constellation point in qask/cir"); - endif + nsig = varargin{2}; + if (!isvector(nsig)) + error ("modmap: invalid number of constellation point in qask/cir"); + endif endif if (nargin > 5) - amp = varargin{3}; + amp = varargin{3}; endif if (nargin > 6) - phs = varargin{4}; + phs = varargin{4}; endif c = apkconst(nsig,amp,phs); M = length(c); elseif (findstr(method,"/arb")) if (nargin == 4) - c = qaskenco(2); + c = qaskenco(2); elseif (nargin == 5) - c = varargin{2}; + c = varargin{2}; elseif (nargin == 6) - inphase = varargin{2}; - quadr = varargin{3}; - c = inphase + 1i*quadr; + inphase = varargin{2}; + quadr = varargin{3}; + c = inphase + 1i*quadr; elseif (nargin > 6) - error ("demodmap: too many arguments"); + error ("demodmap: too many arguments"); endif M = length(c); else @@ -229,8 +229,8 @@ z = (b - 1).'; else for i=1:size(y,1) - [a, b] = min(abs(repmat(y(i,:),M,1) - repmat(c,1,size(y,2)))); - z(i,:) = b - 1; + [a, b] = min(abs(repmat(y(i,:),M,1) - repmat(c,1,size(y,2)))); + z(i,:) = b - 1; end endif endif Modified: trunk/octave-forge/main/comm/inst/egolaydec.m =================================================================== --- trunk/octave-forge/main/comm/inst/egolaydec.m 2012-05-11 18:08:42 UTC (rev 10412) +++ trunk/octave-forge/main/comm/inst/egolaydec.m 2012-05-11 18:10:27 UTC (rev 10413) @@ -49,78 +49,78 @@ function [C,dec_error]=egolaydec(R) -if ( nargin < 1 ) + if ( nargin < 1 ) error('usage: C=egolaydec(R)'); -elseif ( columns(R) ~= 24 ) + elseif ( columns(R) ~= 24 ) error('extended golay code is (24,12), use rx codeword of 24 bit column size'); -end + end -I=eye(12); -%P is 12x12 matrix -P=[1 0 0 0 1 1 1 0 1 1 0 1; - 0 0 0 1 1 1 0 1 1 0 1 1; - 0 0 1 1 1 0 1 1 0 1 0 1; - 0 1 1 1 0 1 1 0 1 0 0 1; - 1 1 1 0 1 1 0 1 0 0 0 1; - 1 1 0 1 1 0 1 0 0 0 1 1; - 1 0 1 1 0 1 0 0 0 1 1 1; - 0 1 1 0 1 0 0 0 1 1 1 1; - 1 1 0 1 0 0 0 1 1 1 0 1; - 1 0 1 0 0 0 1 1 1 0 1 1; - 0 1 0 0 0 1 1 1 0 1 1 1; - 1 1 1 1 1 1 1 1 1 1 1 0;]; + I=eye(12); + %P is 12x12 matrix + P=[1 0 0 0 1 1 1 0 1 1 0 1; + 0 0 0 1 1 1 0 1 1 0 1 1; + 0 0 1 1 1 0 1 1 0 1 0 1; + 0 1 1 1 0 1 1 0 1 0 0 1; + 1 1 1 0 1 1 0 1 0 0 0 1; + 1 1 0 1 1 0 1 0 0 0 1 1; + 1 0 1 1 0 1 0 0 0 1 1 1; + 0 1 1 0 1 0 0 0 1 1 1 1; + 1 1 0 1 0 0 0 1 1 1 0 1; + 1 0 1 0 0 0 1 1 1 0 1 1; + 0 1 0 0 0 1 1 1 0 1 1 1; + 1 1 1 1 1 1 1 1 1 1 1 0;]; -H=[I; P]; %partiy check matrix transpose. + H=[I; P]; %partiy check matrix transpose. -dec_error=[]; -C=zeros(size(R)); + dec_error=[]; + C=zeros(size(R)); -for rspn=1:rows(R) - RR=R(rspn,:); - S=mod(RR*H,2); -wt=sum(S); -done=0; -if (wt <= 3) - E=[S, zeros(1,12)]; - done=1; -else - SP = mod(repmat(S,[12, 1])+P,2); - idx = find( sum(SP,2) <= 2 ); - if ( idx ) + for rspn=1:rows(R) + RR=R(rspn,:); + S=mod(RR*H,2); + wt=sum(S); + done=0; + if (wt <= 3) + E=[S, zeros(1,12)]; + done=1; + else + SP = mod(repmat(S,[12, 1])+P,2); + idx = find( sum(SP,2) <= 2 ); + if ( idx ) idx=idx(1); %pick first of matches. Ui=zeros(1,12); Ui(idx)=1; E=[SP(idx,:),Ui]; done=1; + end end -end -if ( ~done ) - X=mod(S*P,2); - wt=sum(X); - if (wt==2 || wt==3) + if ( ~done ) + X=mod(S*P,2); + wt=sum(X); + if (wt==2 || wt==3) E=[zeros(1,12), X]; done=1; - else + else SP = mod(repmat(X,[12, 1])+P,2); idx = find( sum(SP,2) == 2 ); if ( idx ) - idx=idx(1); - Ui=zeros(1,12); Ui(idx)=1; - E=[Ui,SP(idx,:)]; - done=1; + idx=idx(1); + Ui=zeros(1,12); Ui(idx)=1; + E=[Ui,SP(idx,:)]; + done=1; end + end end -end -dec_error=[dec_error; 1-done]; -C(rspn,:)=mod(E+RR,2); -end + dec_error=[dec_error; 1-done]; + C(rspn,:)=mod(E+RR,2); + end -return; + return; end -%! -%!assert(egolaydec([1 1 1 zeros(1,21)]),zeros(1,24)) -%!assert(egolaydec([1 0 1 zeros(1,20) 1]),zeros(1,24)) -%! + %! + %!assert(egolaydec([1 1 1 zeros(1,21)]),zeros(1,24)) + %!assert(egolaydec([1 0 1 zeros(1,20) 1]),zeros(1,24)) + %! Modified: trunk/octave-forge/main/comm/inst/egolayenc.m =================================================================== --- trunk/octave-forge/main/comm/inst/egolayenc.m 2012-05-11 18:08:42 UTC (rev 10412) +++ trunk/octave-forge/main/comm/inst/egolayenc.m 2012-05-11 18:10:27 UTC (rev 10413) @@ -39,32 +39,32 @@ ## @seealso{egolaygen,egolaydec} function C=egolayenc(M) -if ( nargin < 1 ) + if ( nargin < 1 ) error('usage: C=egolayenc(M)'); -elseif ( columns(M) ~= 12 ) + elseif ( columns(M) ~= 12 ) error('extended golay code is (24,12), use message of column size 12'); -end + end -I=eye(12); -P=[1 0 0 0 1 1 1 0 1 1 0 1; - 0 0 0 1 1 1 0 1 1 0 1 1; - 0 0 1 1 1 0 1 1 0 1 0 1; - 0 1 1 1 0 1 1 0 1 0 0 1; - 1 1 1 0 1 1 0 1 0 0 0 1; - 1 1 0 1 1 0 1 0 0 0 1 1; - 1 0 1 1 0 1 0 0 0 1 1 1; - 0 1 1 0 1 0 0 0 1 1 1 1; - 1 1 0 1 0 0 0 1 1 1 0 1; - 1 0 1 0 0 0 1 1 1 0 1 1; - 0 1 0 0 0 1 1 1 0 1 1 1; - 1 1 1 1 1 1 1 1 1 1 1 0;]; -G=[P I]; %generator. + I=eye(12); + P=[1 0 0 0 1 1 1 0 1 1 0 1; + 0 0 0 1 1 1 0 1 1 0 1 1; + 0 0 1 1 1 0 1 1 0 1 0 1; + 0 1 1 1 0 1 1 0 1 0 0 1; + 1 1 1 0 1 1 0 1 0 0 0 1; + 1 1 0 1 1 0 1 0 0 0 1 1; + 1 0 1 1 0 1 0 0 0 1 1 1; + 0 1 1 0 1 0 0 0 1 1 1 1; + 1 1 0 1 0 0 0 1 1 1 0 1; + 1 0 1 0 0 0 1 1 1 0 1 1; + 0 1 0 0 0 1 1 1 0 1 1 1; + 1 1 1 1 1 1 1 1 1 1 1 0;]; + G=[P I]; %generator. -##for rowi=1:rows(M) -## C(rowi,:)=mod(M(rowi,:)*G,2); %code. -##end + ##for rowi=1:rows(M) + ## C(rowi,:)=mod(M(rowi,:)*G,2); %code. + ##end -C=mod(M*repmat(G,[1,rows(M)]),2); -C=C(:,1:24); + C=mod(M*repmat(G,[1,rows(M)]),2); + C=C(:,1:24); end Modified: trunk/octave-forge/main/comm/inst/egolaygen.m =================================================================== --- trunk/octave-forge/main/comm/inst/egolaygen.m 2012-05-11 18:08:42 UTC (rev 10412) +++ trunk/octave-forge/main/comm/inst/egolaygen.m 2012-05-11 18:10:27 UTC (rev 10413) @@ -24,18 +24,18 @@ ## @seealso{egolaydec,egolayenc} function [G,P]=egolaygen() -I=eye(12); -P=[1 0 0 0 1 1 1 0 1 1 0 1; - 0 0 0 1 1 1 0 1 1 0 1 1; - 0 0 1 1 1 0 1 1 0 1 0 1; - 0 1 1 1 0 1 1 0 1 0 0 1; - 1 1 1 0 1 1 0 1 0 0 0 1; - 1 1 0 1 1 0 1 0 0 0 1 1; - 1 0 1 1 0 1 0 0 0 1 1 1; - 0 1 1 0 1 0 0 0 1 1 1 1; - 1 1 0 1 0 0 0 1 1 1 0 1; - 1 0 1 0 0 0 1 1 1 0 1 1; - 0 1 0 0 0 1 1 1 0 1 1 1; - 1 1 1 1 1 1 1 1 1 1 1 0;]; -G=[P I]; %generator. + I=eye(12); + P=[1 0 0 0 1 1 1 0 1 1 0 1; + 0 0 0 1 1 1 0 1 1 0 1 1; + 0 0 1 1 1 0 1 1 0 1 0 1; + 0 1 1 1 0 1 1 0 1 0 0 1; + 1 1 1 0 1 1 0 1 0 0 0 1; + 1 1 0 1 1 0 1 0 0 0 1 1; + 1 0 1 1 0 1 0 0 0 1 1 1; + 0 1 1 0 1 0 0 0 1 1 1 1; + 1 1 0 1 0 0 0 1 1 1 0 1; + 1 0 1 0 0 0 1 1 1 0 1 1; + 0 1 0 0 0 1 1 1 0 1 1 1; + 1 1 1 1 1 1 1 1 1 1 1 0;]; + G=[P I]; %generator. end Modified: trunk/octave-forge/main/comm/inst/encode.m =================================================================== --- trunk/octave-forge/main/comm/inst/encode.m 2012-05-11 18:08:42 UTC (rev 10412) +++ trunk/octave-forge/main/comm/inst/encode.m 2012-05-11 18:10:27 UTC (rev 10413) @@ -106,31 +106,31 @@ else ## Why the hell did matlab decide on such an ugly way of passing 2 args! if (strcmp(typ,"linear") || strcmp(typ,"linear/binary")) - coding = "linear"; - msgtyp = "binary"; + coding = "linear"; + msgtyp = "binary"; elseif (strcmp(typ,"linear/decimal")) - coding = "linear"; - msgtyp = "decimal"; + coding = "linear"; + msgtyp = "decimal"; elseif (strcmp(typ,"cyclic") || strcmp(typ,"cyclic/binary")) - coding = "cyclic"; - msgtyp = "binary"; + coding = "cyclic"; + msgtyp = "binary"; elseif (strcmp(typ,"cyclic/decimal")) - coding = "cyclic"; - msgtyp = "decimal"; + coding = "cyclic"; + msgtyp = "decimal"; elseif (strcmp(typ,"bch") || strcmp(typ,"bch/binary")) - coding = "bch"; - msgtyp = "binary"; + coding = "bch"; + msgtyp = "binary"; elseif (strcmp(typ,"bch/decimal")) - coding = "bch"; - msgtyp = "decimal"; + coding = "bch"; + msgtyp = "decimal"; elseif (strcmp(typ,"hamming") || strcmp(typ,"hamming/binary")) - coding = "hamming"; - msgtyp = "binary"; + coding = "hamming"; + msgtyp = "binary"; elseif (strcmp(typ,"hamming/decimal")) - coding = "hamming"; - msgtyp = "decimal"; + coding = "hamming"; + msgtyp = "decimal"; else - error ("encode: unrecognized coding and/or message type"); + error ("encode: unrecognized coding and/or message type"); endif endif else @@ -173,31 +173,31 @@ else if (strcmp(coding,"linear")) if (nargin > 4) - gen = opt; - if ((size(gen,1) != k) || (size(gen,2) != n)) - error ("encode: generator matrix is in incorrect form"); - endif + gen = opt; + if ((size(gen,1) != k) || (size(gen,2) != n)) + error ("encode: generator matrix is in incorrect form"); + endif else - error ("encode: linear coding must supply the generator matrix"); + error ("encode: linear coding must supply the generator matrix"); endif elseif (strcmp(coding,"cyclic")) if (nargin > 4) - [par, gen] = cyclgen(n,opt); + [par, gen] = cyclgen(n,opt); else - [par, gen] = cyclgen(n,cyclpoly(n,k)); + [par, gen] = cyclgen(n,cyclpoly(n,k)); endif else m = log2(n + 1); if ((m != floor(m)) || (m < 3) || (m > 16)) - error ("encode: codeword length must be of the form '2^m-1' with integer m"); + error ("encode: codeword length must be of the form '2^m-1' with integer m"); endif if (k != (n-m)) - error ("encode: illegal message length for hamming code"); + error ("encode: illegal message length for hamming code"); endif if (nargin > 4) - [par, gen] = hammgen(m, opt); + [par, gen] = hammgen(m, opt); else - [par, gen] = hammgen(m); + [par, gen] = hammgen(m); endif endif code = mod(msg * gen, 2); Modified: trunk/octave-forge/main/comm/inst/eyediagram.m =================================================================== --- trunk/octave-forge/main/comm/inst/eyediagram.m 2012-05-11 18:08:42 UTC (rev 10412) +++ trunk/octave-forge/main/comm/inst/eyediagram.m 2012-05-11 18:10:27 UTC (rev 10413) @@ -106,7 +106,7 @@ if (isempty(_off)) off = 0; elseif (!isscalar(_off) || !isreal(_off) || (floor(_off) != _off) || ... - (_off < 0) || (_off > (n-1))) + (_off < 0) || (_off > (n-1))) error ("eyediagram: offset must be an integer between 0 and n"); else off = _off; Modified: trunk/octave-forge/main/comm/inst/fibodeco.m =================================================================== --- trunk/octave-forge/main/comm/inst/fibodeco.m 2012-05-11 18:08:42 UTC (rev 10412) +++ trunk/octave-forge/main/comm/inst/fibodeco.m 2012-05-11 18:10:27 UTC (rev 10413) @@ -36,44 +36,44 @@ ## @seealso{fiboenco} function num=fibodeco(code) - % - % generate fibonacci series table. - % - % f(1)=1; - % f(2)=1; - % - % while ((f(end-1)+f(end)) < 256) - % val=(f(end-1)+f(end)); - % f=[f val]; - % end - % f=f(2:end); - % - %all numbers terminate with 1 except 0 itself. - % - % - %f= [75025 46368 28657 17711 10946 6765 4181 2584 \ - % 1597 987 610 377 233 144 89 55 \ - % 34 21 13 8 5 3 2 1]; - % - %f= [ 233 144 89 55 34 21 13 8 5 3 2 1]; + ## + ## generate fibonacci series table. + ## + ## f(1)=1; + ## f(2)=1; + ## + ## while ((f(end-1)+f(end)) < 256) + ## val=(f(end-1)+f(end)); + ## f=[f val]; + ## end + ## f=f(2:end); + ## + ##all numbers terminate with 1 except 0 itself. + ## + ## + ##f= [75025 46368 28657 17711 10946 6765 4181 2584 \ + ## 1597 987 610 377 233 144 89 55 \ + ## 34 21 13 8 5 3 2 1]; + ## + ##f= [ 233 144 89 55 34 21 13 8 5 3 2 1]; - f= [ 1 2 3 5 8 13 21 34 55 89 144 233]; - L_C=length(code); + f= [ 1 2 3 5 8 13 21 34 55 89 144 233]; + L_C=length(code); - if (nargin < 1) - error("Usage:fibodec(cell-array vectors), where each vector is +ve sequence of numbers ... - either 1 or 0"); - end + if (nargin < 1) + error("Usage:fibodec(cell-array vectors), where each vector is +ve sequence of numbers ... + either 1 or 0"); + end - for j=1:L_C - word=code{j}; - %discard the terminating 1. - word=word(1:end-1); - L=length(word); - num(j)=sum(word.*f(1:L)); - end - - return + for j=1:L_C + word=code{j}; + ##discard the terminating 1. + word=word(1:end-1); + L=length(word); + num(j)=sum(word.*f(1:L)); + end + + return end %! %! assert(fibodeco({[1 1],[0 1 1],[0 0 1 1],[1 0 1 1]}),[1:4]) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |