changeset 10043:09628d428bdf octave-forge

control-devel: plotting for frequency-domain iddata
author paramaniac
date Sun, 15 Apr 2012 15:18:34 +0000
parents 0e13b0ba5c1a
children 1abe39dcf962
files extra/control-devel/inst/@iddata/plot.m
diffstat 1 files changed, 59 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/extra/control-devel/inst/@iddata/plot.m	Sun Apr 15 14:29:54 2012 +0000
+++ b/extra/control-devel/inst/@iddata/plot.m	Sun Apr 15 15:18:34 2012 +0000
@@ -29,32 +29,64 @@
   [n, p, m, e] = size (dat);
   expname = __labels__ (dat.expname, "exp");
 
-  if (m == 0)  # time series
-    for k = 1 : e
-      if (k > 1)
-        pause
-      endif
-      plot (dat.y{k})
-      title (expname{k})
-      % hold on
-    endfor
-  else         # inputs present
-    for k = 1 : e
-      if (k > 1)
-        pause
-      endif
-      subplot (2, 1, 1)
-      plot (dat.y{k})
-      title (expname{k})
-      legend (__labels__ (dat.outname, "y"){:})
-      % hold on
-      subplot (2, 1, 2)
-      stairs (dat.u{k})
-      legend (__labels__ (dat.inname, "u"){:})
-      % hold on
-    endfor
+  if (dat.timedomain)
+    if (m == 0)         # time series
+      for k = 1 : e
+        if (k > 1)
+          pause
+        endif
+        plot (dat.y{k})
+        title (expname{k})
+        legend (__labels__ (dat.outname, "y"){:})
+        % hold on
+      endfor
+    else                # inputs present
+      for k = 1 : e
+        if (k > 1)
+          pause
+        endif
+        subplot (2, 1, 1)
+        plot (dat.y{k})
+        title (expname{k})
+        legend (__labels__ (dat.outname, "y"){:})
+        % hold on
+        subplot (2, 1, 2)
+        stairs (dat.u{k})
+        legend (__labels__ (dat.inname, "u"){:})
+        % hold on
+      endfor
+    endif
+  else                  # frequency domain
+    if (m == 0)         # time series
+      for k = 1 : e
+        if (k > 1)
+          pause
+        endif
+        bar (dat.w{k}, 20*log10 (abs (dat.y{k})))
+        xlim ([dat.w{k}(1), dat.w{k}(end)])
+        title (expname{k})
+        legend (__labels__ (dat.outname, "y"){:})
+      endfor
+    else                # inputs present
+      for k = 1 : e
+        if (k > 1)
+          pause
+        endif
+        subplot (2, 1, 1)
+        bar (dat.w{k}, 20*log10 (abs (dat.y{k})))
+        xlim ([dat.w{k}(1), dat.w{k}(end)])
+        title (expname{k})
+        legend (__labels__ (dat.outname, "y"){:})
+        subplot (2, 1, 2)
+        bar (dat.w{k}, 20*log10(abs (dat.u{k})))
+        xlim ([dat.w{k}(1), dat.w{k}(end)])
+        legend (__labels__ (dat.inname, "u"){:})
+      endfor
+    endif
   endif
-  
-  hold off
+
+  ## TODO: think about the 20*log10 and the bars in general
 
-endfunction
\ No newline at end of file
+  % hold off
+
+endfunction