[go: up one dir, main page]

0% found this document useful (0 votes)
5 views19 pages

1.exploration With CAS-I.Lab1

The document outlines an exploration lab using SCILAB, an open-source software for numerical computations and plotting. It covers installation, basic operations, and the use of script files to enhance computational skills for engineering students. Additionally, it provides exercises to practice arithmetic operations and functions within SCILAB.

Uploaded by

subhash.chandra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views19 pages

1.exploration With CAS-I.Lab1

The document outlines an exploration lab using SCILAB, an open-source software for numerical computations and plotting. It covers installation, basic operations, and the use of script files to enhance computational skills for engineering students. Additionally, it provides exercises to practice arithmetic operations and functions within SCILAB.

Uploaded by

subhash.chandra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 19

Exploration with CAS-I

C1UC122B(Lab)

Objectives:

• To enhance the numerical computational


skills of prospective engineers using open
source software/ computer algebra system(CAS)
SCILAB

• To plot graphs of complicated functions .


Experiment-1:Starting with Scilab
• Objectives:
1.1 What is SCILAB?
1.2. How to Install Scilab?
1.3.Working in the console
1.4.Arithmetic Operations with scalars
1.5.Elementary Math Build-in functions
1.6.Defining scalar variables
1.7.Script Files
1.1 What is SCILAB
• It is a software for Numerical computations
2D/3D Plotting.
• It is free and open source software.
• Available for various operating systems(OS)
e.g. Windows, Linux and Mac OS/X
• Its syntax is simple.
• Many numerical problems can be expressed in a
reduced number of code lines, as compared to
similar solutions using traditional languages.
1.1 What is SCILAB
• It is a software for Numerical computations
2D/3D Plotting.
• It is free and open source software.
• Available for various operating systems(OS)
e.g. Windows, Linux and Mac OS/X
• Its syntax is simple.
• Many numerical problems can be expressed in a
reduced number of code lines, as compared to
similar solutions using traditional languages.
Continued….

• CNES (French Space Satellite Agency)


using Scilab successfully.

• IIT Mumbai: Shifting all computational


labs to Scilab
1.2. How to Install Scilab
• Visit: www.scilab.org.
• Various versions of Scilab available for different
Operating systems
• Download the file as per the operating system
in your computer.
• And run it in your computer.
• An icon of Scilab is created on your desktop.
• Double click on the icon and we are in Scilab
environment: File browser, console, variable
browser and command history.
• I am using scilab-6.0.1 for the windows
platform in my system
1.3.Working in the console

• Console is the main window of Scilab


• Used for executing commands(Instructions)
• Opening other windows
• Running programs written by the user

• The ‘prompt’ : -->


The horizontal inbuilt arrow on console is called prompt in
front of which we write instruction(s) called command line.
• role of ‘enter key’: We get the output of our calculations
done on console by pressing the enter key. It is also used
to write new command line
• ‘ans=’ as the default variable:
Continued…
• Role of commas ,
We can write Multiple commands on same command line separated by commas ,
--> 2,3,5
ans =
2.
ans =
3.
ans =
5.

• Role of semicolon ;
If a semicolon(;) is typed at the end of a command the output of the command is not
displayed
--> 2;3;5
ans =
5.
• Role of commands: clc and clear
clc is used to clear the console though data will still remain stored in the memory
clear removes data from memory
1.4.Arithmetic Operations with scalars

Operation Scilab Symbol Example


Addition + -->3+4
ans=
7
Subtraction - -->4-2
ans=
2
Multiplication * -->3*4
ans=
12
Division / -->3/4
ans=
0.75
Exponential ^ -->3^4
ans=
81 (means 34=81)
Order of precedence

Precedence Mathematical Operation


First Parenthesis (Brackets)
Second Exponential
Third Multiplication , Division( equal
Precedence)

Fourth Addition ,Subtraction( equal Precedence)


Exercises

Compute:
(i)7+8/2
(ii) (7+8)/2
(iii) ( 4+2X5)/7
(iv) 271/3+ 320.2
(Answrs: (i)11, (ii)7.5, (iii)2, (iv) 5
1.5.Elementary Math Build-in functions

Function Description Scilab Command Example


Square root sqrt(x) -->sqrt(81)
ans=
9
Real nth root of a real nthroot(x,n) -->nthroot(80,5)
number x ans=
2.4022489
Exponential(ex) exp(x) -->exp(5)
ans=
148.41316
Natural log(base e). log(x) -->log(1000)
ln ans=
6.9078
Base 10 logarithm. log10(x) -->log10(1000)
log ans=
3.0000
Continued…

Function Description Scilab Command Example

x! factorial(x) -->factorial(5)
ans=
120

%pi -->%pi/3
 ans=
1.0471976

Complex number %i -->2+3*%i


ans=
i 1 2. + 3.i

Sine of angle x (x in radians) sin(x) -->sin(%pi/6)


ans=
0.5

Sine of angle x (x in degrees) sind(x) -->sind(30)


ans=
0.5
1.6.Defining scalar variables

• A variable is a name made of a letter or a


combination of several letters that is assigned
a numerical value.
• = sign is called the assignment operator. It
assigns a value to a variable.
• x=15 means the number 15 is assigned to the
variable x
• A variable is actually a name of memory
location where the variable’s assignment is
stored .
1.7.Script Files

• Why we need Script files?


• Using the console to execute a series of
commands is not convenient:
(i)The commands in the console can not be
saved and executed again.
(ii) Every time the enter key is pressed only
the last command is executed, and everything
executed before is unchanged. We can not
edit the previous commands.
1.7.Script Files(Continued…)

• What are Script files?


• A different(better) way of executing commands is first to create a
file with a list of commands(program), save it, and then
run(execute) the file.
• A script file is a sequence of Scilab commands( also called a
program)
• When a script file runs, Scilab executes the commands in the
order they are written just as if they were typed in the console.
• When a script file has a command that generates an out put, the
output is displayed in the console.
• Using an script file is convenient because it can be edited and
executed many times.
• Script files can be typed and edited in any text editor and then
pasted in to the scilab editor(also called scinotes)
1.7.Script Files(Continued…)

• Creating, saving and executing a Script file


• Scilab script files are created and edited in the editor
window( also called scinotes window)
• To Open the Editor:
Click on the Launch SciNotes icon of the toolbar given at
the top
• Creating script file:
Compute: a=(4+2X5)/7
• To save our work done on editor:
Click on the save as icon of the toolbar given at the top.
select the folder(or Create a new folder) > name the file
> select save.
1.7.Script Files(Continued…)

• Creating, saving and executing a Script file


(continued…)
• Command line for display of the output of our
computation a done on Editor on console:
disp(a) or disp(a, ‘a=‘)
• Click on the save and execute icon on the tool bar of
the Editor.
• Go to the console and you will see the output
displayed there.
• To Open our SciNotes files:
Click on the open icon given on the tool bar of the
Editor > select the file to be opened > select open
Excercises
• To write a Scilab code to find the solution of following problems:
• 1. Evaluate:
 0
4
(i) 27 + 32 , (ii) 64  e , (iii)
1/3 0.2 sin  cos 60
6
(iv) 4!+ln2+log100, (v) (2+3i)(4+5i)
2. By assigning values 2 and 5 to variables a and b respectively,
compute (i) c=(a+b)2
(ii) d=4a-3b+lna+ c2
3.Write the script file for the problem:
The radius of a circle is 2cm. Find its area.

You might also like