changeset 9416:c6356bcda43c octave-forge

control: replace num2cell + cellfun by arrayfun (arrayfun became an oct-file in octave 3.6.0)
author paramaniac
date Thu, 09 Feb 2012 17:41:11 +0000
parents d44e0401b147
children 36a7360cccc2
files main/control/inst/@frd/__sys_group__.m main/control/inst/@frd/display.m main/control/inst/@ss/__freqresp__.m main/control/inst/@tf/__sys2ss__.m main/control/inst/ctrb.m main/control/inst/strseq.m
diffstat 6 files changed, 26 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/main/control/inst/@frd/__sys_group__.m	Thu Feb 09 14:14:36 2012 +0000
+++ b/main/control/inst/@frd/__sys_group__.m	Thu Feb 09 17:41:11 2012 +0000
@@ -1,4 +1,4 @@
-## Copyright (C) 2010   Lukas F. Reichlin
+## Copyright (C) 2010, 2012   Lukas F. Reichlin
 ##
 ## This file is part of LTI Syncope.
 ##
@@ -22,7 +22,7 @@
 
 ## Author: Lukas Reichlin <lukas.reichlin@gmail.com>
 ## Created: October 2010
-## Version: 0.1
+## Version: 0.2
 
 function retsys = __sys_group__ (sys1, sys2)
 
@@ -53,11 +53,10 @@
   else                                       # differing frequency vectors
     ## find common frequencies
     retsys.w = w = intersect (sys1.w, sys2.w);
-    w = num2cell (w);
 
     ## indices of common frequencies
-    w1_idx = cellfun (@(x) find (sys1.w == x), w);
-    w2_idx = cellfun (@(x) find (sys2.w == x), w);
+    w1_idx = arrayfun (@(x) find (sys1.w == x), w);
+    w2_idx = arrayfun (@(x) find (sys2.w == x), w);
 
     ## extract common responses
     H1 = sys1.H(:, :, w1_idx);
--- a/main/control/inst/@frd/display.m	Thu Feb 09 14:14:36 2012 +0000
+++ b/main/control/inst/@frd/display.m	Thu Feb 09 17:41:11 2012 +0000
@@ -1,4 +1,4 @@
-## Copyright (C) 2010, 2011   Lukas F. Reichlin
+## Copyright (C) 2010, 2011, 2012   Lukas F. Reichlin
 ##
 ## This file is part of LTI Syncope.
 ##
@@ -20,7 +20,7 @@
 
 ## Author: Lukas Reichlin <lukas.reichlin@gmail.com>
 ## Created: February 2010
-## Version: 0.1
+## Version: 0.2
 
 function display (sys)
 
@@ -123,13 +123,12 @@
   vec = vec(:);
   tmp = isfinite (vec);
   tmp = abs (vec(tmp & vec != 0));
-  vec = num2cell (vec);
   if (isempty (tmp) || min (tmp) < 1e-3 || max (tmp) > 1e4)
-    str = cellfun (@(x) sprintf ("%.3e", x), vec, "uniformoutput", false);
+    str = arrayfun (@(x) sprintf ("%.3e", x), vec, "uniformoutput", false);
   elseif (all (floor (tmp) == tmp))
-    str = cellfun (@(x) sprintf ("%d", x), vec, "uniformoutput", false);
+    str = arrayfun (@(x) sprintf ("%d", x), vec, "uniformoutput", false);
   else
-    str = cellfun (@(x) sprintf ("%.4f", x), vec, "uniformoutput", false);
+    str = arrayfun (@(x) sprintf ("%.4f", x), vec, "uniformoutput", false);
   endif
   str = strjust (char (str), "right");
   if (nargin > 1)
--- a/main/control/inst/@ss/__freqresp__.m	Thu Feb 09 14:14:36 2012 +0000
+++ b/main/control/inst/@ss/__freqresp__.m	Thu Feb 09 17:41:11 2012 +0000
@@ -1,4 +1,4 @@
-## Copyright (C) 2009, 2010, 2011   Lukas F. Reichlin
+## Copyright (C) 2009, 2010, 2011, 2012   Lukas F. Reichlin
 ##
 ## This file is part of LTI Syncope.
 ##
@@ -20,7 +20,7 @@
 
 ## Author: Lukas Reichlin <lukas.reichlin@gmail.com>
 ## Created: October 2009
-## Version: 0.4
+## Version: 0.5
 
 function H = __freqresp__ (sys, w, resptype = 0, cellflag = false)
 
@@ -35,25 +35,25 @@
   endif
 
   if (isct (sys))  # continuous system
-    s = num2cell (i * w);
+    s = i * w;
   else             # discrete system
-    s = num2cell (exp (i * w * abs (tsam)));
+    s = exp (i * w * abs (tsam));
   endif
 
   switch (resptype)
     case 0         # default system
-      H = cellfun (@(x) c/(x*e - a)*b + d, s, "uniformoutput", false);
+      H = arrayfun (@(x) c/(x*e - a)*b + d, s, "uniformoutput", false);
 
     case 1         # inversed system
-      H = cellfun (@(x) inv (c/(x*e - a)*b + d), s, "uniformoutput", false);
+      H = arrayfun (@(x) inv (c/(x*e - a)*b + d), s, "uniformoutput", false);
 
     case 2         # inversed sensitivity
       j = eye (columns (b));
-      H = cellfun (@(x) j + c/(x*e - a)*b + d, s, "uniformoutput", false);
+      H = arrayfun (@(x) j + c/(x*e - a)*b + d, s, "uniformoutput", false);
 
     case 3         # inversed complementary sensitivity
       j = eye (columns (b));
-      H = cellfun (@(x) j + inv (c/(x*e - a)*b + d), s, "uniformoutput", false);
+      H = arrayfun (@(x) j + inv (c/(x*e - a)*b + d), s, "uniformoutput", false);
 
     otherwise
       error ("ss: freqresp: invalid response type");
--- a/main/control/inst/@tf/__sys2ss__.m	Thu Feb 09 14:14:36 2012 +0000
+++ b/main/control/inst/@tf/__sys2ss__.m	Thu Feb 09 17:41:11 2012 +0000
@@ -128,8 +128,8 @@
   max_len_numq = max (len_numq(:));
   numq = cellfun (@(x) prepad (x, max_len_numq, 0, 2), numq, "uniformoutput", false);
   f = @(y) cellfun (@(x) x(y), numq);
-  s = num2cell (1 : max_len_numq);
-  D = cellfun (f, s, "uniformoutput", false);
+  s = 1 : max_len_numq;
+  D = arrayfun (f, s, "uniformoutput", false);
 
   e2 = diag (ones (p*(max_len_numq-1), 1), -p);
   a2 = eye (p*max_len_numq);
--- a/main/control/inst/ctrb.m	Thu Feb 09 14:14:36 2012 +0000
+++ b/main/control/inst/ctrb.m	Thu Feb 09 17:41:11 2012 +0000
@@ -1,4 +1,4 @@
-## Copyright (C) 2009, 2010   Lukas F. Reichlin
+## Copyright (C) 2009, 2010, 2012   Lukas F. Reichlin
 ## Copyright (C) 2009 Luca Favatella <slackydeb@gmail.com>
 ##
 ## This file is part of LTI Syncope.
@@ -53,7 +53,7 @@
 
 ## Author: Lukas Reichlin <lukas.reichlin@gmail.com>
 ## Created: October 2009
-## Version: 0.2
+## Version: 0.3
 
 function co = ctrb (a, b)
 
@@ -71,9 +71,9 @@
   endif
 
   n = rows (a);          # number of states
-  k = num2cell (0:n-1);  # exponents for a
+  k = 0:n-1;             # exponents for a
 
-  tmp = cellfun (@(x) a^x*b, k, "uniformoutput", false);
+  tmp = arrayfun (@(x) a^x*b, k, "uniformoutput", false);
 
   co = horzcat (tmp{:});
 
--- a/main/control/inst/strseq.m	Thu Feb 09 14:14:36 2012 +0000
+++ b/main/control/inst/strseq.m	Thu Feb 09 17:41:11 2012 +0000
@@ -1,4 +1,4 @@
-## Copyright (C) 2009, 2010   Lukas F. Reichlin
+## Copyright (C) 2009, 2010, 2012   Lukas F. Reichlin
 ##
 ## This file is part of LTI Syncope.
 ##
@@ -28,7 +28,7 @@
 
 ## Author: Lukas Reichlin <lukas.reichlin@gmail.com>
 ## Created: September 2009
-## Version: 0.2
+## Version: 0.3
 
 function strvec = strseq (str, idx)
 
@@ -36,8 +36,6 @@
     print_usage ();
   endif
 
-  idx = reshape (num2cell (idx), [], 1);
-
-  strvec = cellfun (@(x) sprintf ("%s%d", str, x), idx, "uniformoutput", false);
+  strvec = arrayfun (@(x) sprintf ("%s%d", str, x), idx(:), "uniformoutput", false);
 
 endfunction
\ No newline at end of file