changeset 9663:44714082301e octave-forge

prbs_iterator, prbs_sequence: use print_usage, tabs per spaces, and specify end blocks
author carandraug
date Tue, 13 Mar 2012 03:51:05 +0000
parents 7e364201a793
children 3d2706e7d133
files main/comm/inst/prbs_iterator.m main/comm/inst/prbs_sequence.m
diffstat 2 files changed, 22 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/main/comm/inst/prbs_iterator.m	Tue Mar 13 03:43:28 2012 +0000
+++ b/main/comm/inst/prbs_iterator.m	Tue Mar 13 03:51:05 2012 +0000
@@ -47,10 +47,11 @@
 ## See Also: This function is to be used along with functions 
 ## prbs_iterator, prbs_generator and prbs_sequence.
 
-function [outputseq,prbs]=prbs_iterator(prbs,iterations)
-  if ( nargin < 2 )
-    iterations=2^(prbs.reglen)-1;
-  end
+function [outputseq, prbs] = prbs_iterator (prbs, iterations = 2^(prbs.reglen)-1)
+
+  if ( nargin < 1 || nargin > 2 )
+    print_usage;
+  endif
   outputseq=zeros(1,iterations);
   nstate=zeros(1,prbs.reglen);
   
@@ -65,10 +66,10 @@
       val=0;
       L=length(prbs.connections{itr2});
       for itr3=2:L
-	val=bitxor(val,prbs.sregs(prbs.connections{itr2}(itr3)));
-      end
+        val=bitxor(val,prbs.sregs(prbs.connections{itr2}(itr3)));
+      endfor
       nstate(prbs.connections{itr2}(1))=val;
-    end
+    endfor
     
     ## rotate the output discarding the last output.
     prbs.sregs=[0 prbs.sregs(1:prbs.reglen-1)];
@@ -77,10 +78,10 @@
     for itr2=1:prbs.conlen
       prbs.sregs(itr2)=nstate(itr2);
       nstate(itr2)=0; # reset.
-    end
+    endfor
     
-  end
-end
+  endfor
+endfunction
 
 ##
 ##  TEST CASES FOR PRBS.
--- a/main/comm/inst/prbs_sequence.m	Tue Mar 13 03:43:28 2012 +0000
+++ b/main/comm/inst/prbs_sequence.m	Tue Mar 13 03:51:05 2012 +0000
@@ -42,13 +42,10 @@
 ## prbs_generator.
 
 function [itrs,seq]=prbs_sequence(prbs)
-  if nargin < 1
-    error("usage: prbs_sequence(prbs struct ); \
-	create the prbs sequence using prbs_generator() function. \
-	This function generates the ML length sequence of 1 period\
-	and returns to the user.")
-  end
-  nstate=zeros(1,prbs.reglen); 
+  if nargin != 1
+    print_usage;
+  endif
+  nstate=zeros(1,prbs.reglen);
   itrs=0; seq = [];
   inits = prbs.sregs;
   
@@ -62,10 +59,10 @@
       val=0;
       L=length(prbs.connections{itr2});
       for itr3=2:L
-	val=bitxor(val,prbs.sregs(prbs.connections{itr2}(itr3)));
-      end
+        val=bitxor(val,prbs.sregs(prbs.connections{itr2}(itr3)));
+      endfor
       nstate(prbs.connections{itr2}(1))=val;
-    end
+    endfor
     
     ## rotate the output discarding the last output.
     seq = [seq, prbs.sregs(end)];
@@ -75,10 +72,10 @@
     for itr2=1:prbs.conlen
       prbs.sregs(itr2)=nstate(itr2);
       nstate(itr2)=0; # reset.
-    end
+    endfor
     
     if(isequal(prbs.sregs,inits))
-      break;
-    end
-  end
+      break
+    endif
+  endwhile
 end