help with plot

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

help with plot

tarcisio praciano pereira
[hidden email] (discussion) [hidden email] (bug
reports)
Platforms:   Most Unix-like systems that have a working g++/libg++.
For graphics, Octave also requires gnuplot.
Keywords: matlab, octave, matrix, mathematics, gnuplot
Author: [hidden email] (John W. Eaton)
Maintained-by: [hidden email]
Primary-site: ftp.che.utexas.edu


Help

Why the octave does'nt understand my  gplot - line 9 ? How could I
define
expression so it can gnuplot-display graphics?


***********begining of file interf.data ***********************
# data-sheet for Octave, does'nt work for Gnuplot
# set term latex; set output 'interf.tex'
set title 'graficos de funcoes'
set xrange [-10:10]; set yrange [0:3]
function y = A (x) 1/(1+((x-4)/5)**2) endfunction
function y = B (x) 1/(1+((x+4)/5)**2) endfunction
function y = C (x) 1/(1+(x/5)**2) + 0.1*sin(2*x) endfunction
# x = (-11:11)
gplot  -11:11 -20:20 A(x),B(x),C(x) using points;
# gplot  y=A(x),y=B(x),y=C(x) using points;
#A(4)
#B(-4)
#C(0)
# pause -1


Thanks, Tarcisio


Reply | Threaded
Open this post in threaded view
|

Re: help with plot

Ted.Harding
( Re Message From: tarcisio praciano pereira )

>
> Why the octave does'nt understand my  gplot - line 9 ? How could I
> define
> expression so it can gnuplot-display graphics?
>
>
> ***********begining of file interf.data ***********************
> # data-sheet for Octave, does'nt work for Gnuplot
> # set term latex; set output 'interf.tex'
> set title 'graficos de funcoes'
> set xrange [-10:10]; set yrange [0:3]
> function y = A (x) 1/(1+((x-4)/5)**2) endfunction
> function y = B (x) 1/(1+((x+4)/5)**2) endfunction
> function y = C (x) 1/(1+(x/5)**2) + 0.1*sin(2*x) endfunction
> # x = (-11:11)
> gplot  -11:11 -20:20 A(x),B(x),C(x) using points;
> # gplot  y=A(x),y=B(x),y=C(x) using points;
> #A(4)
> #B(-4)
> #C(0)
> # pause -1

It would take too long to explain everything that is wrong with the above
as an octave file. Basically, however, there are only a few "pure" gnuplot
commands that you can write in octave, to be passed straight through to
gnuplot. Gnuplot syntax mostly causes errors in octave, and a gnuplot data
file simply will not work as an octave file (with a few very simple
exceptions).

The following (in a form as near to gnuplot syntax as I can get it)
should work:

function y = A (x); y=1./(1+((x-4)/5).^2); endfunction
function y = B (x); y=1./(1+((x+4)/5).^2); endfunction
function y = C (x); y=1./(1+(x/5).^2) + 0.1*sin(2*x); endfunction
x = (-11:11);

gset title 'graficos de funcoes'              
gset xrange [-10:10]; gset yrange [0:3]
gset data style points
plot( x,A(x), x,B(x), x,C(x) );

Please note EVERY difference between the above and your original: each
difference prevents an octave error, warning, or unwanted behaviour.

I hope this helps.
Ted.                                    ([hidden email])