help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: passing strings to GNUplot


From: Karim Elaagouby
Subject: Re: passing strings to GNUplot
Date: Fri, 21 Aug 1998 17:10:10 -0700

Hi everyone,

"gset" is pretty heavy to use. I wrote the following function which
works sort
of "print" in matlab ! 

on my linux machine.

===============================================================

# print.m
#
# Usage:  print
# or      print( device_name );
#
#  with argument will print to the default **postscript** printer
#  with -Pprintername will print to the specified printer
#
#  otherwise, it will print to the specified file
#  
#  For use with UNIX OS
#
#  Karim Elaagouby idealab! address@hidden
#

function print( devFile )
     lpCmd = "| lpr ";
     devStr="";
     returnFlag = 0;
     USAGE_MSG="Usage: print or print( filename|-Pprintername ) ";
     msg="";

     if ( nargin == 1)
        if (isstr(devFile))
           if ( length(devFile) < 3 )
               msg = USAGE_MSG;
               returnFlag = 1;
           elseif ( devFile(1:2) == "-P") 
               devStr = [lpCmd , devFile ];
           else 
               devStr = devFile;
           endif;
        else 
           msg = "Argument must be a string !" ;
           returnFlag = 1 ;
        endif;
     else 
        devStr = lpCmd;
     endif;

     if ( returnFlag == 1)
        disp( msg);
        return;
     endif

     gset term postscript
     eval ([ "gset output \""  devStr "\"" ]);
     replot
     gset term x11
endfunction;


================================================================


Mario Storti wrote:
> 
> >>>>> On Fri, 21 Aug 1998 14:13:41 -0600 (MDT),
> >>>>>      "David D. Clark" <address@hidden> said:
> 
> > Is there a way to pass a file name stored as a string to the gnuplot
> > command "output"
> 
> > pfile="data.ps"
> > gset output pfile
> 
> > this results in the error:
> 
> octave> pfile="data.ps"
> octave> gset output pfile
> octave>
> gnuplot> set output pfile
> >                     ^
> >          line 0: expecting filename
> 
> > any help would be appreciated
> 
> > Dave
> 
> First of all you have to quote the filename, and secondly you must use
> eval since gnuplot cannot expand strings .
> 
> Use
> 
> octave> eval(["gset output \"" pfile "\""])
> 
> Mario

--
Karim Elaagouby
Information Systems Analyst
idealab! 
130 W. Union St. 
Pasadena, CA 91103
address@hidden
626/535-2779 Direct
626/585-6900 Reception
626/535-2701 fax



reply via email to

[Prev in Thread] Current Thread [Next in Thread]