help-octave
[Top][All Lists]
Advanced

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

Re: problems


From: Carlo De Falco
Subject: Re: problems
Date: Thu, 1 Oct 2015 10:06:45 +0000

On 29 Sep 2015, at 19:20, Robert Setif <address@hidden> wrote:

> I would like to know why the file:
>  "
>   # hyp.m
>   function r=hyp(x,y)
>   # hypoténuse d'un triangle de côtés x et y
>   r=sqrt(x*x+y*y)
>   endfunction
>  "
> always alert :
>     " 
>    >> hyp
>    error: 'x' undefined near line 4 column 8
>    error: called from
>     hyp at line 4 column 2
>    error: evaluating argument list element number 1
>    error: called from
>     hyp at line 4 column 2
>  "
> Fortunately, this is not a crashing error.
> That problem happens with all my files.
> I do not know to declare in function-arguments a variable, 
>  for instance x as real, y as integer, m as scalar.
>  
> I also would like to change at the screen the shape of result 
>  from a  "for i=1:30,disp(i^2),endfor"  in order to 
>  request in a list-shape rather that column-shape, 
>  (with "disp" or another command).
>  Regards

Hi,

Your file defines a function which requires two input arguments,
if you call it without arguments the variables 'x' and 'y' will
not be defined in the internal scope, which results in this error.

Note that this is an error, not a warning, which means the function
is not run and return values are not set.

See this section of the manual for more information:
http://www.gnu.org/software/octave/doc/interpreter/Functions-and-Scripts.html#Functions-and-Scripts

HTH,
c.





reply via email to

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