Back to index

texmacs  1.0.7.15
__plt2mv__.m
Go to the documentation of this file.
00001 ## Copyright (C) 1996, 1997 John W. Eaton
00002 ##
00003 ## This file is part of Octave.
00004 ##
00005 ## Octave is free software; you can redistribute it and/or modify it
00006 ## under the terms of the GNU General Public License as published by
00007 ## the Free Software Foundation; either version 2, or (at your option)
00008 ## any later version.
00009 ##
00010 ## Octave is distributed in the hope that it will be useful, but
00011 ## WITHOUT ANY WARRANTY; without even the implied warranty of
00012 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 ## General Public License for more details.
00014 ##
00015 ## You should have received a copy of the GNU General Public License
00016 ## along with Octave; see the file COPYING.  If not, write to the Free
00017 ## Software Foundation, 59 Temple Place - Suite 330, Boston, MA
00018 ## 02111-1307, USA.
00019 
00020 ## -*- texinfo -*-
00021 ## @deftypefn {Function File} {} __plt2mv__ (@var{x}, @var{y}, @var{fmt})
00022 ## @end deftypefn
00023 
00024 ## Author: jwe
00025 
00026 ## Modified: Jan. 2003 -- Added TeXmacs interface support
00027 ## Author: Michael Graffam <mgraffam@mathlab.sunysb.edu>
00028 
00029 function __plt2mv__ (x, y, fmt)
00030 
00031   if (nargin < 2 || nargin > 3)
00032     msg = sprintf ("__plt2mv__ (x, y)\n");
00033     msg = sprintf ("%s              __plt2mv__ (x, y, fmt)", msg);
00034     usage (msg);
00035   elseif (nargin == 2 || fmt == "")
00036     fmt = " ";  ## Yes, this is intentionally not an empty string!
00037   endif
00038 
00039   if (length(getenv("TEXMACS_PATH"))>0)
00040        gset output '/tmp/tmplot.eps';
00041   endif
00042 
00043   [x_nr, x_nc] = size (x);
00044   [y_nr, y_nc] = size (y);
00045 
00046   if (y_nr == 1)
00047     y = y';
00048     tmp = y_nr;
00049     y_nr = y_nc;
00050     y_nc = tmp;
00051   endif
00052 
00053   if (x_nr == y_nr)
00054     1;
00055   elseif (x_nc == y_nr)
00056     x = x';
00057     tmp = x_nr;
00058     x_nr = x_nc;
00059     x_nc = tmp;
00060   else
00061     error ("__plt2mv__: matrix dimensions must match");
00062   endif
00063 
00064   k = 1;
00065   fmt_nr = rows (fmt);
00066   if (x_nc > 0)
00067     tmp = [x, y];
00068     cmd = sprintf ("gplot tmp(:,%d:%d:%d) %s", 1, x_nc, x_nc+1,
00069                    deblank (fmt (k, :)));
00070     if (k < fmt_nr)
00071       k++;
00072     endif
00073     for i = 2:x_nc
00074       cmd = sprintf ("%s, tmp(:,%d:%d:%d) %s", cmd, i, x_nc-i+1, x_nc+1,
00075                      deblank (fmt (k, :)));
00076       if (k < fmt_nr)
00077         k++;
00078       endif
00079     endfor
00080     eval (cmd);
00081           if (length(getenv("TEXMACS_PATH"))>0)
00082                  P=[2;112;115;58]; #P= "\002ps:"
00083                 g=fopen("/tmp/tmplot.eps");
00084                 while (g==-1)
00085                         sleep(1);
00086                         g=fopen("/tmp/tmplot.eps");
00087                 endwhile
00088                 while (!feof(g))
00089                         f=fread(g,2048);
00090                         if (length(f))
00091                                 P=[P;f];
00092                         endif
00093                 endwhile
00094                 fclose(g);
00095                 P=[P;5];
00096                 disp(sprintf("%cverbatim:\n",2));
00097                 disp(setstr(P'));
00098                 system("rm /tmp/tmplot.eps");
00099         endif
00100 
00101   else
00102     error ("__plt2mv__: arguments must be a matrices");
00103   endif
00104 
00105 endfunction