[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: |
Sun, 20 Sep 2015 00:07:17 +0000 |
User-agent: |
Mozilla/5.0 (Windows NT 6.3; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0 |
URL:
<http://savannah.gnu.org/bugs/?46004>
Summary: ezplot fails to recognise functions with 2 arguments
passed as handles
Project: GNU Octave
Submitted by: tpapastylianou
Submitted on: Sun 20 Sep 2015 00:07:16 GMT
Category: Plotting
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Incorrect Result
Status: None
Assigned to: None
Originator Name: Tasos Papastylianou <tpapastylianou>
Originator Email:
Open/Closed: Open
Discussion Lock: Any
Release: 4.0.0
Operating System: Any
_______________________________________________________
Details:
To replicate:
Create a function f.m
%% in file f.m
function Out = f(a,b)
if nargin < 2; b = 5; end
Out = a-b;
end
Then at the terminal, compare:
ezplot(@f,[0,10,0,10]);
with:
ezplot(@(a,b) a-b, [0,10,0,10]);
The results should be the same, but they're not. Octave treats the function as
a single argument function.
(The two commands give the same output in Matlab as expected)
The error lies in line 135 of private function __ezplot__.m, which is called
by ezplot.m
This assumes erroneously that if the function handle passed in is not an
anonymous function, then it must necessarily come from a function with a
single argument; clearly this neglects functions with two arguments which are
also valid input for ezplot.
Suggested fix:
Add the following line below line 135:
if evalin('base',['nargin(''' func2str(fun) ''')']) == 2; args{2} = "y"; end
Many thanks,
T.
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?46004>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #46004] ezplot fails to recognise functions with 2 arguments passed as handles,
Tasos Papastylianou <=