octave-maintainers
[Top][All Lists]
Advanced

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

Re: why is octave such a crap?


From: Ben Abbott
Subject: Re: why is octave such a crap?
Date: Wed, 17 Aug 2016 11:15:57 -0400

On Aug 17, 2016, at 10:50, Frank Zack <address@hidden> wrote:

function retval=octsux(x)
  if(x<1.3)                         % -inf<x<1.3
    retval=1/(exp(-x(1))+0.27);
  else                                 % 1.3<=x<inf
    retval=4/(3*sqrt(pi))*(x(1)^2+pi^2/6)^(3/4);
  endif  
endfunction

octsux(10)

warning: function name 'octsux' does not agree with function file name '/user/ME/test.m'
error: 'x' undefined near line 2 column 6
error: called from

wtf?

I assume you placed the example above in '/user/ME/test.m'?

The problem is that test.m is being parsed as a function and the parser is confused because the file name implies the function name is test() but the function declaration specifies octsux().

If the first line of your file is anything other than a comment or a function declaration it would work.

Try placing the text below in usux.m 

## start
1;
function retval=octsux(x)
  if(x<1.3)                         % -inf<x<1.3
    retval=1/(exp(-x(1))+0.27);
  else                                 % 1.3<=x<inf
    retval=4/(3*sqrt(pi))*(x(1)^2+pi^2/6)^(3/4);
  endif  
endfunction

octsux(10)
## end

And type 'usux' at octave's prompt

Ben ;-)

reply via email to

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