Global Institute of Engineering and Technology
Global Institute of Engineering and Technology
LAB MANUAL
Programme (UG/PG) : UG
Semester : I
Prepared By
Exp.
Title
No.
1 Introduction
5 GRAPHICS - 2D PLOTS
1. 2. 4.
4. 7. 1.
6. 3. 1.
LOGICAL OPERATORS:
a=0;b=10;
if a and b
disp("Condition is true");
else
disp("Condition is false");
end
if a or b
disp("Condition is true");
end
if (~a)
disp("Condition is true");
end
exec('C:\Users\admin\Documents\relational.sce', -1)
Condition is false
Condition is true
Boolean Matrices
Boolean constants are %t and %f. They can be used in Boolean matrices. The syntax is the
same as for ordinary matrices i.e. they can be concatenated, transposed, etc... Operations symbols
used with Boolean matrices or used to create Boolean matrices are == and ˜.
Similarly,
[ 3,3] == [3,4]
This produces
and
ans =
! TF!
s = 1:6 ; s(s>3)
will display,
ans =
! 4. 5. 6. !
Similarly,
A = [%t %f %t %f], B = [%f %t %f %t]
produces,
A=
and
! TF T F ! B=
! FTFT!
A|B // logical OR
ans =
! TTTT!
! FFFF!
RESULT
Study of basic SCI Lab commands on arithmetic, Logical,Boolean Operations are worked and
executed
EXP. NO: 2
2. 7. 3.
4. 1. 1.
max(Y)
ans =
7.
Mathematical operations
Sin(z) – Retrieve the sine value for the given matrix / vector
sin(Y)
ans =
Similar operation can be obtained for Cos, tan, sec, csc, cot. The hyperbolic for sine, cosine
etc can be retrieved using sinh, cosh etc.
Inverse of cosine, sine can be obtained using the acos, asin etc
Log10(z) and log(z) provides the base 10 & natural logarithm for the given vector and matix
log(Y)
ans =
0. 1.3862944 1.7917595
0.6931472 1.9459101 1.0986123
1.3862944 0. 0.
Sqrt(z) provides the square root for the matrix elements.
sqrt(Y)
ans =
1. 2. 2.4494897
1.4142136 2.6457513 1.7320508
2. 1. 1.
Performing addition, subtraction, multiplication and division for array vectors or matrix
elements
nthroot(Y,4)
ans =
1. 1.4142136 1.5650846
1.4142136 1. 1.
sign(Y)
ans = 1. 1. 1.
1. 1. 1.
1. 1. 1.
Cat(1,y,z) – concatenates the array / vector ‘y’ with ‘z’ row wise
Y = 1. 4. 6.
2. 7. 3.
4. 1. 1.
Z =
9. 8. 7.
5. 6. 4.
3. 2. 1.
cat(1,Y,Z)
ans =
1. 4. 6.
2. 7. 3.
4. 1. 1.
9. 8. 7.
5. 6. 4.
3. 2. 1.
Cat(2,y,z) – concatenates the array / vector ‘y’ with ‘z’ column wise
2.5615528
RESULT :
If-Else statement
EXP. NO: 3
i. OBJECTIVE: To write and execute programs that demonstrate on Control
Structures (If-Else, If-elseif –else, Select) using SCI Notes.
ii. ALGORITHM:
STEP 4: pmodulo(number,2) tells if the number is divisible by 2. By which the the given
number odd or even is determined.
STEP 6: The dayNum returns the number for the given system date ie. Sun is considered
1, Mon = 2 , Tue = 2 etc.
STEP 8: Using dayString, the different cases are dealt and the statements are dealt
accordingly.
STEP 9: A number is taken as input and checked for positive or negative or zero using the
if-elseif – else condition.
SELECT STATEMENTS:
To print on what day we are in a week
[dayNum,dayString]=weekday(datenum());
select dayString
case "Mon" then
disp("Start of work week");
case "Tue" then
disp("Day2");
case "Wed" then
disp("Day3");
case "Thu" then
disp("Day4");
case "Fri" then
disp("Last day of work week");
else
disp("Weekend");
end
exec('C:\Users\admin\Documents\if.sce', -1)
Enter a number:5
Number is odd
-->exec('C:\Users\admin\Documents\if.sce', -1)
Enter a number:6
Number is even
SELECT STATEMENTS:
--
>exec('C:\Users\admin\Documents\select.s
exec('C:\Users\admin\Documents\nestedif.sce', -1)
Enter a
number:4
positive
--
>exec('C:\Users\admin\Documents\nestedif.sc
e', -1) Enter a number:0
Zero
-->exec('C:\Users\admin\Documents\nestedif.sce', -1)
Enter a
number:-7
negative
RESULT :
The programs are executed using if-else, select, if-else if-else statements.