help-octave
[Top][All Lists]
Advanced

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

How to plot an user-defined function?


From: Fausto Arinos de A. Barbuto
Subject: How to plot an user-defined function?
Date: Fri, 01 Aug 2003 12:21:13 -0600


Dear All:

        Let the following functions f(t) and g(t) be:

function y = f(t)
   y = exp(-0.5*t*t);
endfunction

function z = g(t)
   z = (1.0/sqrt(2.0*pi))*quad('f',-10.0, t, 1e-12);
endfunction

        Now I want to plot g(t). However, an attempt like:

t = linspace(-10,10,2000);
plot(t, g(t))

        fails. What I want to do is to plot several values for
the integration of the probability function (but it could be
anything else) from -10 to an arbitrary "t". The error message
is as follows:

error: __plt2vv__: vector lengths must match
error: evaluating if command near line 55, column 3
error: called from `__plt2vv__' in file
`/usr/share/octave/2.1.36/m/plot/__plt2vv__.m'
error: called from `__plt2__' in file `/usr/share/octave/2.1.36/m/plot/__plt2__.m' error: called from `__plt__' in file `/usr/share/octave/2.1.36/m/plot/__plt__.m'
error: called from `plot' in file `/usr/share/octave/2.1.36/m/plot/plot.m'

        However, g(1), g(2), g(2.72), etc, work well, that is, the
function is OK.

>> g(2.72)
ans = 0.99674

        Any hints?

TIA,

---Fausto



-------------------------------------------------------------
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]