octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #46004] ezplot fails to recognise functions wi


From: Tasos Papastylianou
Subject: [Octave-bug-tracker] [bug #46004] ezplot fails to recognise functions with 2 arguments passed as handles
Date: Mon, 21 Sep 2015 23:32:51 +0000
User-agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0

Follow-up Comment #4, bug #46004 (project octave):

Hi Rik. Thanks for the explanation about nargin; I wasn't aware of this
substitution.
I can confirm that


if builtin ("nargin", fun) == 2; args{2} = "y"; end


in  __ezplot.m__  (placed under line 135) works as expected and fixes the
bug.

The correct output should be from  ezplot (@(a,b) a - b, [ 0, 10, 0, 10]) 

Since @f is a handle to a function expecting two inputs, the output should
have been identical.

I apologise, I used an example where the bug was a bit subtle, in that it
produces the wrong graph, only because that was the scenario where I came
across it. In reality it doesn't have to be subtle at all. Consider the
following:

* in function f.m:


function Out = f(a,b)
  Out = a-b;
end


(note there's no nargin check to provide a default value for b this time. If b
isn't provided, this function will simply result in an error.)

* then at the terminal:


>> ezplot(@f, [0,10,0,10])
error: 'b' undefined near line 2 column 11
error: called from
    f at line 2 column 7
    __ezplot__ at line 399 column 13
    ezplot at line 76 column 19


Line 399 of  __ezplot__.m  is:


Z = feval (fun, X);


In other words,  __ezplot__  has branched down to a point in a nested if block
where it tries to evaluate fun using only one argument, hence it fails. The
reason it inappropriately reaches that part at all is because of the bug at
line 135, which makes the assumption that any handle derived from a simple
function will always only have one argument, and implicitly results in setting
the second argument to "". This assumption is false, hence the fix to check
for a second argument and act accordingly.


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?46004>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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