Professional Documents
Culture Documents
STEPS DESCRPTION
Take the problem you are trying to solve
Planning the Program and break it down into a series of smaller,
independent tasks. Implement each task
as a separate function. Try to keep
functions fairly short, each
having a single purpose.
Using Pseudo-Code Write the initial draft of your program in a
structured format using your own natural
language. This pseudo-code is often
easier to think through, review, and modify
than using a formal programming
language, yet it is easily translated
into a programming language in the next
stage of development.
[Type here]
Computer Services Centre, IIT, Delhi.
SCILAB Workshop
reshape(A); diag(A);
(ii) To extract a submatrix B consisting of rows 1 and 3 and
columns 1 and 2 of the matrix A.
(iii) To interchange rows 1 and 3 of A, use the vector of row
indices together with the colon operator
(iv) Using the zeros, ones and eye commands create the
following matrix.
rd
d) To delete a 3 row from matrix A
(A)
(i) Compare the results of the following entries: a=[1,2,3], b=[1 2
3], and c=[1;2;3]
(ii) Type cos(pi) and cos(180). Which is the answer that you’d
expect?
[Type here]
solve 3x=17 (iv) e2 -1/e2 +1
(v) Suppose that u=1 and v=3. Evaluate the following
expressions using scilab
(a)
4u / (v3)
4 2
pi v
3
c)
(d) A trigonometric identity is given by:
x tan x + sin x
2 =
cos 2 2 tan x
[Type here]
Verify that the identity is correct by calculating each side of
the equation, substituting x= π /5.
(e )
(i) Create a row vector that has the elements: 32,4,81,63,
cos( π /10), and 14.24.
(ii) Create a row vector with 15 equally spaced elements
element is -15.
(iv) Create a ten-dimensional row vector whose all
components are equal 2. You cannot enter number 2
more than once.
(vi ) With A= 1 2 3 4
matrix 5 6 6 7
8 9 10 1
11 12 13 1
1
Perform the following operations: 4
rd
• Extract the 3 column from matrix A and store it in
vector B.
st rd
• Extract the 1 and 3 columns from matrix A
and store them in matrix C .
st rd
• Add the 1 and 3 rows from matrix A
together and store the result in vector D.
nd rd
• Change the value in 2 row and 3 column of
matrix A to -7 and Call the result AA.
[Type here]
rd
• Create a matrix that contains rows 1 and 3 from
A, second row of AA and the result of D.
[Type here]
(h) Type a=bob+5 and then b=bob+3. Try the following
operations: a-b, a.^2, a.*b, and a*b. Why does a*b return an
error?
3 by 5
A.
columns of A.
[Type here]
(iv) Create the following matrix D 4 by 7 matrix
st rd
1. Create a 3 by 4 matrix B from the 1 , 3 , and
th st rd th th
4 rows and 1 , 3 through 5 and 7
columns of the matrix D.
th th
elements of the third row and the 5 and 7
columns of the matrix D.
be:
A= 1 1 1 0 0
1 1 1 0 0
1 1 1 0 0
0 0 0 5 5
0 0 0 5 5
[Type here]
(V) Create the following matrix A:
1 2 3 4 5 6 7
2 4 6 8 10 12 14
A=
21 18 15 12 9 6 3
5 10 15 20 25 30 35
st rd th
a) Create a 3 x 4 matrix B from the 1 ,3 and 4 rows and
st rd th th
the 1 , 3 through 5 and 7 columns pf the matrix A.
b) B) create a 15 elements-log row vector u from the elements
th
of the third row, and 5
th
and 7 columns of the matrix A.
(v) Using the Zeros and ones commands, create a 3x5 matrix
in which the first, second, and fifth columns are 0’s and the
third and fourth columns are 1’s.
9⎥⎦
⎣6 ⎣1
Compute the following matrix
computations:
AB , BA , A+B , A+C ,BC,
T
CC , CC .
Which of the computations could not be
computed ?
NOTES:
Special Commands
help
apropos(key)
[y] = testmatrix(name, n)
Operators
[Type here]
.' (Matlab operator) — Elementwise transpose
== (Matlab operator) — Equal to
> (Matlab operator) — Greater than
>= (Matlab operator) — Greater or equal to
\ (Matlab operator) — Left division
< (Matlab operator) — Smaller than
<= (Matlab operator) — Smaller or equal to
* (Matlab operator) — Multiplication
~ (Matlab operator) — Negation
~= (Matlab operator) — Not equal to
| (Matlab operator) — Logical OR
^ (Matlab operator) — Exponent
/ (Matlab operator) — Right division
- (Matlab operator) — Minus
' (Matlab operator) — Transpose
Scilab keywords
ans — answer
backslash — (\) left matrix division.
brackets [,;] — Concatenation. Recipients of an assignment.
Results of a function
colon — (:) colon operator
comma — (,) comma; instruction, argument separator
comments — (// or /*...*/) comments
comparison — comparison, relational operators
dollar — ($) last index
dot — (.) symbol
equal — (=) assignment , comparison, equal sign
extraction — matrix and list entry extraction
getscilabkeywords — returns a list with all scilab keywords.
hat — (^) exponentiation
assignation — partial variable assignation
great — (>) greater than comparison
minus — (-) subtraction operator, sign changes
not — (~) logical not
parentheses — ( ) left and right parenthesis
percent — (%) special character
plus — (+) addition operator
quote — (') transpose operator, string delimiter
semicolon — (;) ending expression and row separator
slash — (/) right division and feed back
[Type here]
star — (*) multiplication operator
symbols — scilab operator names
tilde — (~) logical not
Control flow
[Type here]