octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #60291] Function parameters not supported when


From: Lars Kindermann
Subject: [Octave-bug-tracker] [bug #60291] Function parameters not supported when calling from the shell
Date: Thu, 1 Apr 2021 21:56:54 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0

Follow-up Comment #4, bug #60291 (project octave):

@Rik, thanks, that's of course the obvious solution for writing shell- and
Octave-callable functions. I suggest to add your hint to chapter "2.6
Executable Octave Programs" of the doc, as it may be helpful for other people
like me who will not figure this out by themselves. E.g:


To write m-files that can act as executable programs when called from the
shell and also as normal functions within Octave, default input arguments set
by the argv() function can be used.
When a function is called from the shell, Octave will not pass anything to the
function inputs, so the default would be used instead:

#!/usr/local/bin/octave -qf
function retval = mysin (x = str2double (argv(){end}))
  retval = sin (x)
endfunction

This can be called from the shell with

    mysin.m 5

or from Octave with

    mysin (5)


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?60291>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

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