Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > b38d2da330d1936e5ab1307c039c4941 > files > 46

octave-doc-3.6.4-3.mga4.noarch.rpm

<html lang="en">
<head>
<title>Functions defined on the command-line - Frequently asked questions about Octave (with answers)</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Frequently asked questions about Octave (with answers)">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Octave-Features.html#Octave-Features" title="Octave Features">
<link rel="next" href="Comments-with-_0023.html#Comments-with-_0023" title="Comments with #">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
  pre.display { font-family:inherit }
  pre.format  { font-family:inherit }
  pre.smalldisplay { font-family:inherit; font-size:smaller }
  pre.smallformat  { font-family:inherit; font-size:smaller }
  pre.smallexample { font-size:smaller }
  pre.smalllisp    { font-size:smaller }
  span.sc    { font-variant:small-caps }
  span.roman { font-family:serif; font-weight:normal; } 
  span.sansserif { font-family:sans-serif; font-weight:normal; } 
--></style>
</head>
<body>
<div class="node">
<a name="Functions-defined-on-the-command-line"></a>
<a name="Functions-defined-on-the-command_002dline"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="Comments-with-_0023.html#Comments-with-_0023">Comments with #</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Octave-Features.html#Octave-Features">Octave Features</a>
<hr>
</div>

<h3 class="section">5.1 Functions defined on the command-line</h3>

<p>Functions can be defined by entering code on the command line, a feature
not supported by <span class="sc">Matlab</span>. For example, you may type:

<pre class="example">     octave:1&gt; function s = hello_string (to_who)
     &gt; ## Say hello
     &gt; if nargin&lt;1, to_who = "World"; end
     &gt; s = ["Hello ",\
     &gt;      to_who];
     &gt; endfunction
     octave:2&gt; hello_string ("Moon")
     ans = Hello Moon
</pre>
   </body></html>