Introducing 

Prezi AI.

Your new presentation assistant.

Refine, enhance, and tailor your content, source relevant images, and edit visuals quicker than ever before.

Loading…
Transcript

Scilab Programming Language

Melanie Wu

12-A

1. Installing the program

1. Installing the program

Scilab on Cloud

https://cloud.scilab.in/

Scilab on Cloud

Scilab org

https://www.scilab.org/

Scilab org

2. Running the program

2. Running the program

Scilab on Cloud facilitates execution of the codes for particular example(s) online. The results can then be verified with the solved example(s) from the textbook. It is also possible to change the values of the variables and in fact, the code itself, and execute it.

3. Basic Syntax / Structure

3. Basic Syntax / Structure

To open the editor from the console, click on the first icon in the toolbar or on Applications > SciNotes in the menu bar. The editor opens with a default file named “ Untitled 1 “.

Typing in the editor is like as in any word processor. In the text editor, opening and closing parentheses, end loops, function and test commands are added automatically. However, these features can be disabled in Options > Auto-completion on menu, in clicking on the two below entries enabled by default:

• (,[,…

• if,function,…

Writing in the editor

The semicolon ";"

While in principle each instruction should be entered on a separate line, it is possible to type multiple statements on a same line separating each statement with a semicolon “ ; “. A space at the start of the line called indentation is automatic when a loop or a test is started.

4. Type of Variables

4. Type of Variables

Integer

a. Integer

Integers are whole numbers represented as binary values. 1 if variable is a integer type, otherwise 0.

Example:

x=uint16(1:10);

inttype(x)

b. Float

Floating point numbers are at the core of numerical computations, as opposed to symbolic computations. The limited precision of floating point

numbers have a fundamental importance in Scilab.

b. Float

Example:

m = grand(3,5,"uin",1,9) .* 10.^grand(3,5,"uin",-16,1)

clean(m)

clean(m, 1e-7)

c. String

A string is any finite sequence of characters. The characters can be either letters, numbers, symbols or punctuation marks.

Example:

c. String

5. Operators

5. Operators

a. Arithmetic

Arithmetic operators are used to perform arithmetic operations on variables and data.

Examples:

a. Arithmetic

b. Relational

A relational operator is used to check the relationship between two operands.

Examples:

b. Relational

c. Logic

In order to perform logical operations in Scilab we can use AND, OR and NOT operators. The logical operators are mostly used within conditional loops like: if, while, etc.

Examples:

c. Logic

d. Assignment

The equal sign = is used to denote the assignment of value(s) to variable(s). The syntax can be : a=expr where a is a variable name and expr a scilab expression which evaluates to a single result; [a,b,...]=

Example:

d.Assignment

6. Comments

A sequence of two consecutive slashes // out of a string definition marks the beginning of a comment. The slashes as well as all the following characters up to the end of the lines are not interpreted.

Example:

6. Comments

7. Conditional Statements

7. Conditional Statements

a. If – Else

The “expr_i” are expressions with numeric or boolean values. The optional ELSEIF and ELSE provide for the execution of alternate groups of statements. An END keyword, which matches the IF, terminates the last group of statements.

a. If – Else

Example:

if expr1 then statements

elseif expr_i then statements

....

else statements

end

Learn more about creating dynamic, engaging presentations with Prezi