diff scripts/plot/__plt2mm__.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/__plt2mm__.m	Fri Jan 21 17:02:21 2005 +0000
+++ b/scripts/plot/__plt2mm__.m	Mon Jan 24 18:38:45 2005 +0000
@@ -18,18 +18,16 @@
 ## 02111-1307, USA.
 
 ## -*- texinfo -*-
-## @deftypefn {Function File} {} __plt2mm__ (@var{x}, @var{y}, @var{fmt})
+## @deftypefn {Function File} {[data, fmtstr] =} __plt2mm__ (@var{x}, @var{y}, @var{fmt})
 ## @end deftypefn
 
 ## Author: jwe
 
-function __plt2mm__ (x, y, fmt)
+function [data, fmtstr] = __plt2mm__ (x, y, fmt)
 
-  if (nargin < 2 || nargin > 3)
-    msg = sprintf ("__plt2mm__ (x, y)\n");
-    msg = sprintf ("%s              __plt2mm__ (x, y, fmt)", msg);
-    usage (msg);
-  elseif (nargin == 2 || fmt == "")
+  if (nargin < 2 || nargin > 3 || nargout != 2)
+    usage ("[data, fmtstr] = __plt2mm__ (x, y, fmt)");
+  elseif (nargin == 2 || isempty (fmt))
     fmt = " ";  ## Yes, this is intentionally not an empty string!
   endif
 
@@ -40,20 +38,18 @@
   fmt_nr = rows (fmt);
   if (x_nr == y_nr && x_nc == y_nc)
     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, x_nc+i,
-                       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+i]);
+	ftmp{i} = deblank (fmt(i,:));
       endfor
-      eval (cmd);
+      data = dtmp;
+      fmtstr = ftmp;
     else
       error ("__plt2mm__: arguments must be a matrices");
     endif