Back to index

texmacs  1.0.7.15
__plt2mm__.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} {} __plt2mm__ (@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 __plt2mm__ (x, y, fmt)
00030 
00031   if (nargin < 2 || nargin > 3)
00032     msg = sprintf ("__plt2mm__ (x, y)\n");
00033     msg = sprintf ("%s              __plt2mm__ (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   [x_nr, x_nc] = size (x);
00040   [y_nr, y_nc] = size (y);
00041 
00042   if (length(getenv("TEXMACS_PATH"))>0)
00043        gset output '/tmp/tmplot.eps';
00044   endif
00045 
00046   k = 1;
00047   fmt_nr = rows (fmt);
00048   if (x_nr == y_nr && x_nc == y_nc)
00049     if (x_nc > 0)
00050       tmp = [x, y];
00051       cmd = sprintf ("gplot tmp(:,%d:%d:%d) %s", 1, x_nc, x_nc+1,
00052                      deblank (fmt (k, :)));
00053       if (k < fmt_nr)
00054         k++;
00055       endif
00056       for i = 2:x_nc
00057         cmd = sprintf ("%s, tmp(:,%d:%d:%d) %s", cmd, i, x_nc, x_nc+i,
00058                        deblank (fmt (k, :)));
00059         if (k < fmt_nr)
00060           k++;
00061         endif
00062       endfor
00063       eval (cmd);
00064 
00065           if (length(getenv("TEXMACS_PATH"))>0)
00066                  P=[2;112;115;58]; #P= "\002ps:"
00067                 g=fopen("/tmp/tmplot.eps");
00068                 while (g==-1)
00069                         sleep(1);
00070                         g=fopen("/tmp/tmplot.eps");
00071                 endwhile
00072                 while (!feof(g))
00073                         f=fread(g,2048);
00074                         if (length(f))
00075                                 P=[P;f];
00076                         endif
00077                 endwhile
00078                 fclose(g);
00079                 P=[P;5];
00080                 disp(sprintf("%cverbatim:\n",2));
00081                 disp(setstr(P'));
00082                 system("rm /tmp/tmplot.eps");
00083         endif
00084 
00085     else
00086       error ("__plt2mm__: arguments must be a matrices");
00087     endif
00088   else
00089     error ("__plt2mm__: matrix dimensions must match");
00090   endif
00091 
00092 endfunction