diff scripts/plot/__plt2mv__.m @ 5115:57372235194b

[project @ 2005-01-24 18:38:45 by jwe]
author jwe
date Mon, 24 Jan 2005 18:38:45 +0000
parents 17826ec287bc
children 4c8a2e4e0717
line wrap: on
line diff
--- a/scripts/plot/__plt2mv__.m
+++ b/scripts/plot/__plt2mv__.m
@@ -18,18 +18,16 @@
 ## 02111-1307, USA.
 
 ## -*- texinfo -*-
-## @deftypefn {Function File} {} __plt2mv__ (@var{x}, @var{y}, @var{fmt})
+## @deftypefn {Function File} {[data, fmtstr] =} __plt2mv__ (@var{x}, @var{y}, @var{fmt})
 ## @end deftypefn
 
 ## Author: jwe
 
-function __plt2mv__ (x, y, fmt)
+function [data, fmtstr] = __plt2mv__ (x, y, fmt)
 
-  if (nargin < 2 || nargin > 3)
-    msg = sprintf ("__plt2mv__ (x, y)\n");
-    msg = sprintf ("%s              __plt2mv__ (x, y, fmt)", msg);
-    usage (msg);
-  elseif (nargin == 2 || fmt == "")
+  if (nargin < 2 || nargin > 3 || nargout != 2)
+    usage ("[data, fmtstr] = __plt2mv__ (x, y, fmt)");
+  elseif (nargin == 2 || isempty (fmt))
     fmt = " ";  ## Yes, this is intentionally not an empty string!
   endif
 
@@ -54,23 +52,19 @@
     error ("__plt2mv__: matrix dimensions must match");
   endif
 
-  k = 1;
-  fmt_nr = rows (fmt);
   if (x_nc > 0)
-    tmp = [x, y];
-    cmd = sprintf ("gplot tmp(:,%d:%d:%d) %s", 1, x_nc, x_nc+1,
-                   deblank (fmt (k, :)));
-    if (k < fmt_nr)
-      k++;
+    if (rows (fmt) == 1)
+      fmt = repmat (fmt, x_nc, 1);
     endif
-    for i = 2:x_nc
-      cmd = sprintf ("%s, tmp(:,%d:%d:%d) %s", cmd, i, x_nc-i+1, x_nc+1,
-                     deblank (fmt (k, :)));
-      if (k < fmt_nr)
-        k++;
-      endif
+    tmp = [x, y];
+    dtmp = cell (x_nc, 1);
+    ftmp = cell (x_nc, 1);
+    for i = 1:x_nc
+      dtmp{i} = tmp(:,[i,x_nc+1]);
+      ftmp{i} = deblank (fmt(i,:));
     endfor
-    eval (cmd);
+    data = dtmp;
+    fmtstr = ftmp;
   else
     error ("__plt2mv__: arguments must be a matrices");
   endif