changeset 9959:031647737003 octave-forge

control-devel: check tsam in cat
author paramaniac
date Wed, 04 Apr 2012 12:47:24 +0000
parents 35a9395eb191
children dd7c71579f89
files extra/control-devel/inst/@iddata/cat.m extra/control-devel/inst/@iddata/fft.m extra/control-devel/inst/@iddata/get.m
diffstat 3 files changed, 20 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/extra/control-devel/inst/@iddata/cat.m	Wed Apr 04 11:24:29 2012 +0000
+++ b/extra/control-devel/inst/@iddata/cat.m	Wed Apr 04 12:47:24 2012 +0000
@@ -96,6 +96,8 @@
   outunit = tmp(1).outunit;
   inname = tmp(1).inname;
   inunit = tmp(1).inunit;
+  
+  check_domain (tmp, e);
 
   switch (dim)
     case 1                                          # vertcat - catenate samples
@@ -140,6 +142,8 @@
   dat.outunit = outunit;
   dat.inname = inname;
   dat.inunit = inunit;
+  
+  % TODO: handle tsam, w
 
 endfunction
 
@@ -155,6 +159,10 @@
     warning ("iddata: cat: experiment names don't match")
   endif
 
+  if (numel (e) > 1 && ! isequal (tmp.tsam))
+    warning ("iddata: cat: sampling times don't match");
+  endif
+
 endfunction
 
 
@@ -201,7 +209,14 @@
            mat2str (vertcat (n{:}), 10));
   endif
 
-  ## TODO: check sampling times
+endfunction
+
+
+function check_domain (tmp, e)
+
+  if (numel (e) > 1 && ! isequal (tmp.timedomain))  # isequal doesn't work with less than 2 arguments
+    error ("iddata: cat: can't mix time- and frequency-domain datasets");
+  endif
 
 endfunction
 
--- a/extra/control-devel/inst/@iddata/fft.m	Wed Apr 04 11:24:29 2012 +0000
+++ b/extra/control-devel/inst/@iddata/fft.m	Wed Apr 04 12:47:24 2012 +0000
@@ -46,28 +46,12 @@
     error ("iddata: fft: second argument invalid");
   endif
 
-%  if ((! is_real_scalar (ord) || fix (ord) != ord) && ! ischar (ord))   # chars are handled by built-in detrend
-%    error ("iddata: detrend: second argument must be a positve integer");
-%  endif
-
-%  dat.y = cellfun (@fft, dat.y, "uniformoutput", false);
-%  dat.u = cellfun (@fft, dat.u, "uniformoutput", false);
-
-%  dat.y = cellfun (@(y, n) fft (y, n) / sqrt (n), dat.y, n, "uniformoutput", false);
-%  dat.u = cellfun (@(u, n) fft (u, n) / sqrt (n), dat.u, n, "uniformoutput", false);
-
   dat.y = cellfun (@(y, n) fft (y, n)(1:fix(n/2)+1, :) / sqrt (n), dat.y, n, "uniformoutput", false);
   dat.u = cellfun (@(u, n) fft (u, n)(1:fix(n/2)+1, :) / sqrt (n), dat.u, n, "uniformoutput", false);
   
-  % w = (0:fix(n/2)) * (2*pi/tsam/n)
-  
   dat.w = cellfun (@(n, tsam) (0:fix(n/2)).' * (2*pi/tsam/n), n, dat.tsam, "uniformoutput", false);
-  
   dat.timedomain = false;
 
-%  dat.y = cellfun (@(y) fft (y, n), dat.y, "uniformoutput", false);
-%  dat.u = cellfun (@(u) fft (u, n), dat.u, "uniformoutput", false);
-
 endfunction
 
 
--- a/extra/control-devel/inst/@iddata/get.m	Wed Apr 04 11:24:29 2012 +0000
+++ b/extra/control-devel/inst/@iddata/get.m	Wed Apr 04 12:47:24 2012 +0000
@@ -62,6 +62,10 @@
           val = dat.notes;
         case "userdata"
           val = dat.userdata;
+        case {"domain", "timedomain"}
+          val = dat.timedomain;
+        case {"w", "frequency", "samplinginstants"}
+          val = dat.w;
         otherwise
           error ("iddata: get: invalid property name '%s'", varargin{k});
       endswitch