[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #53220] Sending strings to quadl
From: |
Rik |
Subject: |
[Octave-bug-tracker] [bug #53220] Sending strings to quadl |
Date: |
Tue, 27 Feb 2018 10:56:30 -0500 (EST) |
User-agent: |
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0 |
Follow-up Comment #3, bug #53220 (project octave):
The quad error message is different because it can actually accept raw code to
execute, rather than the documented first argument for all the other quad
functions:
F is a function handle, inline function, or string containing the
name of the function to evaluate
For example,
quad ("x.^2 + 1", 0, 2)
warning: quad: passing function body as a string is obsolete; please use
anonymous functions
ans = 1.3333
Try the same thing with quadl and you get
quadl ("x.^2 + 1", 0, 2)
error: feval: function 'x.^2 + 1' not found
because it recognizes that the double-quoted object is a string, and therefore
should be the name of a function.
Accordingly, you can either give it a function handle, inline function, or
name of a function that calculates what you want.
octave:5> function y = MYF (x)
> y = x.^2 + 1;
> endfunction
octave:6> quadl ("MYF", 0, 1)
ans = 1.3333
octave:7> quadl (@(x) x.^2 + 1, 0, 1)
ans = 1.3333
octave:8> quadl (inline ("x.^2 + 1"), 0, 1)
ans = 1.3333
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?53220>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/