Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
6.1.0 - English

Change language to:
Français - 日本語 - Português - Русский

Please note that the recommended version of Scilab is 2025.0.0. This page might be outdated.
See the recommended documentation of this function

Scilab Help >> Advanced functions > deff

deff

in-line definition of a function in Scilab language

Syntax

deff('[s1, s2, ...] = newfunction(e1, e2, ...)',text)

Arguments

e1, e2, ...

input variables.

s1, s2, ...

output variables.

text

a matrix of character strings.

Description

deff can be used to define functions from sequences of instructions written in text strings. The resulting function object has the same properties of any other function defined in a text file and loaded with exec.

Quotes included in instructions given in strings must be doubled to be protected.

Examples

deff('x = myplus(y,z)', 'x = y+z')
myplus(1,%i)

deff('[y, z] = mymacro(x)', ['y = 3*x+1'; 'z = a*x + x.^2'])
a = 3;
[u, v] = mymacro(2)
--> deff('x = myplus(y,z)', 'x = y+z')
--> myplus(1,%i)
 ans  =
   1. + i

--> deff('[y, z] = mymacro(x)', ['y = 3*x+1'; 'z = a*x + x.^2'])
--> a = 3;
--> [u, v] = mymacro(2)
 v  =
   10.

 u  =
   7.

See also

  • function — opens a function definition
  • exec — script file execution
  • getd — Load all functions defined in a directory
  • genlib — build library from functions in given directory
  • jdeff — Map a static Java method onto a Scilab macro
  • jcompile — Compile Java code or file

History

VersionDescription
6.0.0
  • The input option opt="c"|"p"|"n" is no longer available.
  • The defined newfunction is now of type 13 (instead of 11).
Report an issue
<< argn Advanced functions exec >>

Copyright (c) 2022-2024 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Tue Feb 25 08:49:22 CET 2020