Use the function in the same way as an embedded Scilab function: ->k = f(2,3) If the function is saved in the working directory, the argument of the exec() function is the name of the custom function file as a string: exec('myFunction.sci')Īfter the function is loaded, it can be called as any embedded Scilab function.Īs an example, let’s define the following mathematical function is Scilab: \[f(x,y)=\left\Īfter running the instruction, all the content of the function will be executed in the Scilab console. To do this we need to use the exec() function. The next step is to load the function in the Scilab environment. This extension informs Scilab that the script file contains a function definition. X1, x2 – function arguments, input variables they need to be separated by a comma ( ,) and enclosed in round brackets ( ) the function can have none, one or multiple arguments įunction content – is the sum of all the Scilab instructions that represents the definition of the function it is also named the body of the function Įndfunction – is a required keyword which must be added to the function definition it defines the end of the function definition Īfter the function is defined, the script file is saved with the extension *.sci. MyFunction – the name of the custom function it needs to be different than the existing embedded Scilab functions and it should not have the same name as a Scilab script file (*.sce) in the same working directory Y1, y2 – return values of the function they have to be separated by a comma ( ,) and enclosed in right brackets the function can have none, one or multiple return values Function – is a required keyword which must be added to the function definition it defines the start of the function definition
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |