bugGNU Octave - Bugs: bug #48034, fplot errors when fn returns a row...

 
 

bug #48034: fplot errors when fn returns a row vector

Submitter:  Muhali <muhali>
Submitted:  Thu 26 May 2016 06:51:18 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Documentation
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 4.0.2 Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 06 Jun 2016 10:56:33 PM UTC, comment #3: 

This is kind of stupid.  The function should respect the orientation of the data input and return output that is oriented in the same way.  However, it isn't that hard to fix either.  fplot now checks to see whether the number of columns matches the number of row inputs and if it is then it always transposes the output of the function evaluation.  The changeset is on the development branch of Octave (http://hg.savannah.gnu.org/hgweb/octave/rev/1077f09a0cfd).

Fixed.  Closing report.

Rik <rik5>
Group administrator
Fri 27 May 2016 12:08:01 AM UTC, comment #2: 

And we could possibly correct for simple errors like this, if fplot is expecting a column vector, but gets back a row vector of the right length, assume that it is correct and transpose it.

Mike Miller <mtmiller>
Group Member
Fri 27 May 2016 12:03:43 AM UTC, comment #1: 

Thanks for the report. I can confirm the error you are seeing with your given function.

I modified it like so to make it work:


function y = fun(x)
      y = zeros(size(x));
      I = (x < 0) ;
      y(I) = 1 ;
      y(~I) = -1 ;
end


The important distinction being that the return value has the same size and shape as the input. Your example returned a row vector regardless of whether the input was a row, column, or matrix.

I think the error checking could be improved to make this clearer, as well as the docstring. Suggestions?

Mike Miller <mtmiller>
Group Member
Thu 26 May 2016 06:51:18 PM UTC, original submission:  

with


function y = fun(x)
      I = (x < 0) ;
      y(I) = 1 ;
      y(~I) = -1 ;
end


the call

fplot(@fun, [-1 1])

results in

error: fplot: operator -: nonconformant arguments (op1 is 8x5, op2 is 8x8)
error: called from
    fplot at line 160 column 9
error: evaluating argument list element number 1
error: called from
    fplot at line 160 column 9
error: evaluating argument list element number 1
error: called from
    fplot at line 160 column 9


The same call works in ML.

Muhali <muhali>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by muhali (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-06-06 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2016-05-27 mtmiller Summaryfplot not working fplot errors when fn returns a row vector
    2016-05-27 mtmiller CategoryNone Octave Function
        Item GroupNone Documentation
        StatusNone Confirmed

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code