[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: problems
From: |
Vic Norton |
Subject: |
Re: problems |
Date: |
Thu, 1 Oct 2015 07:39:37 -0400 |
On Sep 29, 2015, at 1:20 PM, 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
> Robert SETIF address@hidden
I don't understand where your (first) problem is, Robert.
I created a file "hyp.m" in my Octave load path consisting of precisely
# 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
I see no problem with the following result.
octave> clear all
octave> side1 = 3;
octave> side2 = 4;
octave> hypotenuse = hyp(side1, side2)
hypotenuse = 5
- Vic
- problems, Robert Setif, 2015/10/08
- Re: problems, James Sherman Jr., 2015/10/08
- Re: problems,
Vic Norton <=
- Re: problems, Carlo De Falco, 2015/10/08
- Re: problems, Juan Pablo Carbajal, 2015/10/08
- Re: problems, Mike Miller, 2015/10/08
- Re: problems, Doug Stewart, 2015/10/08
- Re: problems, fbarbuto, 2015/10/08