changeset 9532:d88548d176f2 octave-forge

control-devel: work on iddata display routine
author paramaniac
date Tue, 28 Feb 2012 14:11:38 +0000
parents c59c0582009d
children 9e0034f84724
files extra/control-devel/devel/test_iddata.m extra/control-devel/inst/@iddata/display.m
diffstat 2 files changed, 32 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/extra/control-devel/devel/test_iddata.m	Tue Feb 28 12:44:16 2012 +0000
+++ b/extra/control-devel/devel/test_iddata.m	Tue Feb 28 14:11:38 2012 +0000
@@ -10,4 +10,6 @@
 %x.y = {}
 
 %x.u = []
-x.u = x.y
\ No newline at end of file
+x.u = x.y
+
+d = iddata ({(1:10).', (21:25).'}, {(31:40).', (41:45).'})
--- a/extra/control-devel/inst/@iddata/display.m	Tue Feb 28 12:44:16 2012 +0000
+++ b/extra/control-devel/inst/@iddata/display.m	Tue Feb 28 14:11:38 2012 +0000
@@ -40,11 +40,11 @@
   disp (str);
   disp ("");
   
-  disp (__col2str__ (expname, "Experiment"));
+  disp (horzcat (__col2str__ (expname, "Experiment"), __vec2str__ (n, "Samples"), __vec2str__ (cell2mat (dat.tsam), "Sampling Interval")));
   disp ("");
-  disp (__col2str__ (outname, "Outputs"));
+  disp (horzcat (__col2str__ (outname, "Outputs"), __col2str__ (dat.outunit, "Unit (if specified)")));
   disp ("");
-  disp (__col2str__ (inname, "Inputs"));
+  disp (horzcat (__col2str__ (inname, "Inputs"), __col2str__ (dat.inunit, "Unit (if specified)")));
   disp ("");
   
 %{
@@ -71,3 +71,29 @@
   str = strvcat (title, str);
 
 endfunction
+
+
+function str = __vec2str__ (vec, title)
+
+  vec = vec(:);
+  tmp = isfinite (vec);
+  tmp = abs (vec(tmp & vec != 0));
+  if (isempty (tmp) || min (tmp) < 1e-3 || max (tmp) > 1e4)
+    str = arrayfun (@(x) sprintf ("   %.3e", x), vec, "uniformoutput", false);
+  elseif (all (floor (tmp) == tmp))
+    str = arrayfun (@(x) sprintf ("   %d", x), vec, "uniformoutput", false);
+  else
+    str = arrayfun (@(x) sprintf ("   %.4f", x), vec, "uniformoutput", false);
+  endif
+  str = strjust (char (str), "right");
+  %str = [repmat("   ", len, 1), str];
+  str = strvcat (title, str);
+  
+  %if (nargin > 1)
+  %  str = [str, repmat(post, length (vec), 1)];
+  %endif
+
+endfunction
+
+
+