help-octave
[Top][All Lists]
Advanced

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

Stupid New User Question


From: Pat Ferguson
Subject: Stupid New User Question
Date: Tue, 11 Jul 2006 17:37:48 -0400

I have written a simple function:

 

function  retval = killnegatives(x)

     retval = x;

     if(retval<0) retval = 0;

     endif;

endfunction

 

and placed it in a file called “killnegatives.m”.

 

I then fired up octave and this is what happens when I use my function.

 

 

GNU Octave, version 2.1.73 (i686-pc-cygwin).

Copyright (C) 2006 John W. Eaton.

This is free software; see the source code for copying conditions.

There is ABSOLUTELY NO WARRANTY; not even for MERCHANTIBILITY or

FITNESS FOR A PARTICULAR PURPOSE.  For details, type `warranty'.

 

Additional information about Octave is available at http://www.octave.org.

 

Please contribute if you find this software useful.

For more information, visit http://www.octave.org/help-wanted.html

 

Report bugs to <address@hidden> (but first, please read

http://www.octave.org/bugs.html to learn how to write a helpful report).

 

octave:1> T = [-1,1]

T =

 

  -1   1

 

octave:2> killnegatives(T)

ans =

 

  -1   1

 

octave:3> killnegatives(-1)

ans = 0

octave:4> killnegatives (1)

ans = 1

 

 

The function seems to work as I expected when called with a single value, but not with an array.  I am sure the answer to why is obvious to someone and I hope you’ll share.

 

 


reply via email to

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