manpagez: man pages & more
info Octave-FAQ
Home | html | info | man
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1 Functions defined on the command-line

Functions can be defined by entering code on the command line, a feature not supported by the other leading brand. For example, you may type:

 
octave:1> function s = hello_string (to_who)
> ## Say hello 
> if nargin<1, to_who = "World"; end
> s = ["Hello ",\
>      to_who];
> endfunction
octave:2> hello_string ("Moon")
ans = Hello Moon

© manpagez.com 2000-2017
Individual documents may contain additional copyright information.