Download presentation
Presentation is loading. Please wait.
Published byDenis Dixon Modified over 9 years ago
1
Math 15 Lecture 7 University of California, Merced Scilab A “Very” Short Introduction
2
Project #1 – Due 3pm on April 4 th, 2008 UC Merced 2 Projects can be performed individually or in groups of three, with following rules: Teams turn in one project report and get the same grade. A team consists of at most 3 people—no copying between teams! Team project report must include a title page, where a team describe each team member’s contribution. 10% bonus for projects done individually Individual projects must not be copied from anyone else No late project will be accepted! No late project will be accepted! Project #1 has been posted at UCMCROP. 2
3
UC Merced 3 Any Questions?
4
Course Lecture Schedule WeekDateConceptsProject Due 1 2January 28Introduction to the data analysis 3February 4Excel #1 – General Techniques 4February 11Excel #2 – Plotting Graphs/ChartsQuiz #1 5February 18Holiday 6February 25Excel #3 – Statistical AnalysisQuiz #2 7March 3Excel #4 – Regression Analysis 8March 10Excel #5 – Interactive ProgrammingQuiz #3 9March 17Introduction to Computer Programming - Part - I March 24Spring Recesses 10March 31Introduction to Computer Programming - Part - II(4/4) Project #1 11April 7Programming – #1Quiz #4 12April 14Programming – #2 13April 21Programming – #3Quiz #5 14April 28Programming – #4 15May 5Programming - #5Quiz #6 16May 12Movies / EvaluationsProject #2 FinalMay ???Final Examination
5
Outline 1. Scilab 2. Getting Started 3. Simple Operations with Scilab 4. Simple Plots with Scilab 5
6
What is Scilab? Scilab is a numerical, programming and graphics environment available for free from the French Government’s INRIA (National Institute for Informatics and Automation Research). It is similar in operation to MATLAB. It is available for free from the Scilab website www.scilab.org.
7
What is Scilab? Scilab is a software for numerical mathematics and scientific visualization. It is capable of interactive calculations as well as automation of computations through programming. It provides all basic operations on matrices through built-in functions so that the trouble of developing and testing code for basic operations are completely Scilab can help you understand all intermediate steps in solving even complicated problems, as easily as using a calculator.
8
What Scilab can do:
9
www.scilab.org 9
10
UCM Computer Labs
11
Scilab Environment The user enters Scilab commands at the prompt (-->). Scilab can be used as a simple calculator to perform numerical calculations. It also has the ability to define variables and store values in them so that they can be used later.
12
Simple Calculator -->2+3 ans = 5. -->2/3 ans =.6666667 -->2^3 ans = 8. Evaluate -->s=0.5 s = 0.5 -->log(s^2-2*s*cos(s*%pi/2)+1) ans = - 0.6108426 -->
13
Loading a Value Into a Variable --> a = 2 a = 2. -->b = 3. b = 3. -->c = a+b c = 5. --> a = 2 Variable assignment Value 2 is assigned to the variable, a.
14
Variables in Excel UC Merced - Math 15 14 Cell names, such as B1, D1 etc., are variables in Excel. = (B1 – D3*B4)/(A1+B2^3) 3 is assigned to Cell B2.
15
Mathematical Operations Few examples of operations Arithmetic Operations Trigonometric Operations sin(), cos(), tan(), asin(), acos(), atan(), sinh, cosh etc. Exponential and logarithmic operations log(), log10(), exp() etc. +Addition -Subtraction *Multiplication /Division ^Exponentiation 15
16
Examples sqrt(3^5-2)/exp(2) 2.1009686 atan(3)/asin(0.6) 1.9410157 16
17
UC Merced 17 Let’s program! But be careful! --> x = 3 --> y = 3x - 3 --> x = 3 --> y = 3x - 3 Missing Operator error >>> --> x = 3 --> y = 3*x - 3 y = 6.
18
Special Constants SCILAB has a number of special constants: %i unit imaginary number %pi ratio of circumference to diameter %e the base of the natural logarithms %inf the infinity %nan not-a-number %f boolean constant ’false’ %t boolean constant ’true’ Etc. 18
19
Examples 0.0289905 sqrt(3^5-2)/exp(2*%pi) tan(2*%pi/3)/cos(3/%pi) - (sqrt(5)-1)^4 - 5.3327279 19
20
Comments Comments in SCILAB begin with a double forward slash (//) a = 2.5 // redefining a 20
21
Creating Arrays Array You can think as a variable carries series of data i.e. x = 1, 2, 3, 4, 5 How to define arrays in SCILAB. V = [1, 2, 3, 4,5] V = 12345 V = [1:5] // array runs from 1 to 5 by 1. V = 12345 V = 1:2:10 or [1:2:10] // array runs from 1 to 10 by 2. V = 13579 V = linspace(0,10,5) // array has 5 evenly spaced points between 0 and 10. V= 0 2.5 5.0 7.5 10 21
22
Array Operation Row array with starting value, increment, ending value x = -10: 0.1: 10; Applying a function to the array y = sin(x*%pi/10); Plotting the function plot(x,y) 22
23
Working with Arrys X = [1 2 3] Y = [2;1;5] b = 2*x c = 2*y Row array (vector) Column array (vector) 2 4 6 4 2 10 23
24
Working with Arrays –cont. z = [2 1 0]; a = x + z b = x + y c = x.* z 3 3 3 You will get an error. You cannot add (or subtract) a row vector to a column vector You can multiply (or divide) the elements of two same-size arrays (vectors) term by term with the array operator.* (or./) 2 2 0 24
25
Creating Simple Plots Let’s plot with Scilab. First define as an array theta = linspace(0,2*%pi,100); Create a linearly spaced 100 elements between 0 and 2 . Then, calculate y = sin(theta); Then, plot the graph plot(theta,y)
26
More on plotting Let’s plot the following functions on the same graph. theta = linspace(0,2*%pi,100); x = sin(theta); y = cos(theta); plot(theta,x,theta,y,'--') 26
27
Teaching Philosophy UC Merced - Math 15 27 “I hear and I forget. I see and I remember. I do and I understand.” Confucius 500 B.C. No Pain! No Gain!
28
Next Lecture By using Scilab, we can effortlessly solve systems of equations, such as
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.