help-octave
[Top][All Lists]
Advanced

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

Re: problems


From: Mike Miller
Subject: Re: problems
Date: Thu, 1 Oct 2015 08:35:18 -0400
User-agent: Mutt/1.5.24 (2015-08-30)

On Tue, Sep 29, 2015 at 19:20:02 +0200, Robert Setif 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.

The reason for the error is that you have not passed any arguments to
the function call. If you call hyp(3,4) then you should see a better
result.

All m-files in Octave first check for the correct number of arguments:

  if (nargin != 2)
    print_usage ();
  endif


> 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).

Do you perhaps want this?

  [1:30].^2

?

-- 
mike

Attachment: signature.asc
Description: PGP signature


reply via email to

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