help-octave
[Top][All Lists]
Advanced

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

Re: how to create a png from bash or php-file


From: mavram
Subject: Re: how to create a png from bash or php-file
Date: Tue, 7 Dec 2004 06:41:16 +0200
User-agent: Mutt/1.5.5.1+cvs20040105i

On Sun, Dec 05, 2004 at 08:55:39PM +0100, Peter Lischka wrote:
> Hi,
> 
> i have a simple octave-file grph.m:
> 
> function prr
> x=[0:0.1:10];
> y=sin(x);
> plot(x,y);
> % end function
> 
> which creates a simple sinus-plot when i start it in the octave-prompt.
> what i want to know is:
> 
> 1.) how can i run my "grph.m" out from a linux-bash?
> maybe "octave grph.m"?
> but i only got the greeting-text and no plot?
> 
> 2:) how can i run my program out from a php-script (maybe with "shell_exec")
> or from a bash-script, so that i get a file grph.png?
> what commands shall i add in my grph.m-file and what commands do i need to
> add in my php-script/bash-script?
> 
> cheers,
> peter

Hi Peter,
On my system the following ways work
1-Ammend your script to:
#! /usr/bin/octave-2.1.57 -qf
x=[0:0.1:10];
y=sin(x);
plot(x,y);
pause

/usr/bin/octave-2.1.57 is the location of ny octave. Replace by yours
the "pause" is needed to enable you to see the graph. Otherwise, with
nowaday's fast machines it will desappear before.
Of course, if you only need to create the file, you do not need that.
You need the "set term" and the "set output" commands before the "plot"
command.
2-From the command line:
echo "x=[0:0.1:10];y=sin(x);plot(x,y);" | octave -q
or, putting all that in the file grph
cat grph | octave -q

Good luck, Avraham



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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