You are on page 1of 5

Lab #01

OBJECT: Introduction to MATLAB and perform various


functions using MATLAB.
Task 1 b(1,:)

a=[1,2,3] ans =
1 2 3
a=
1 2 3
b(:,1)

a' ans =
1
ans = 4
1 7
2
3
Task 2
b=[1;2;3] a=0:2:20
b= a=
1 0 2 4 6 8 10 12 14 16
2 18 20
3

b=1:2:20
a=[1 2 3]'
b=
a= 1 3 5 7 9 11 13 15 17
1 19
2
3
c=0:0.1:10
c=
b=[1 2 3;4 5 6;7 8 9]
b= Columns 1 through 13
1 2 3
4 5 6 0 0.1000 0.2000 0.3000
7 8 9 0.4000 0.5000 0.6000 0.7000
0.8000 0.9000 1.0000 1.1000
1.2000
Columns 14 through 26 9.5000 9.6000 9.7000 9.8000
9.9000 10.0000
1.3000 1.4000 1.5000 1.6000
1.7000 1.8000 1.9000 2.0000
2.1000 2.2000 2.3000 2.4000 Task 3:
2.5000
a=[1 2 3 5;2 8 9 7;6 4 3 2;7 2 1 2]
Columns 27 through 39
a=
1 2 3 5
2.6000 2.7000 2.8000 2.9000
2 8 9 7
3.0000 3.1000 3.2000 3.3000
6 4 3 2
3.4000 3.5000 3.6000 3.7000
7 2 1 2
3.8000

Columns 40 through 52
b=[8 2 3 1;5 4 9 6;3 2 1 4;4 2 1 4]
3.9000 4.0000 4.1000 4.2000 b=
4.3000 4.4000 4.5000 4.6000 8 2 3 1
4.7000 4.8000 4.9000 5.0000 5 4 9 6
5.1000 3 2 1 4
4 2 1 4
Columns 53 through 65

5.2000 5.3000 5.4000 5.5000 sum=a+b


5.6000 5.7000 5.8000 5.9000
6.0000 6.1000 6.2000 6.3000 sum =
6.4000 9 4 6 6
7 12 18 13
Columns 66 through 78 9 6 4 6
11 4 2 6
6.5000 6.6000 6.7000 6.8000
6.9000 7.0000 7.1000 7.2000
7.3000 7.4000 7.5000 7.6000 sub=a-b
7.7000 sub =
-7 0 0 4
Columns 79 through 91 -3 4 0 1
3 2 2 -2
7.8000 7.9000 8.0000 8.1000 3 0 0 -2
8.2000 8.3000 8.4000 8.5000
8.6000 8.7000 8.8000 8.9000
9.0000 mul=a*b

Columns 92 through 101

9.1000 9.2000 9.3000 9.4000


mul =
47 26 29 45
111 68 94 114
85 38 59 50
77 28 42 31 c=exp(0.5)
c=
1.6487
ELM=a.*b
ELM =
8 4 9 5 Task 6:
10 32 81 42
18 8 3 8 a=1.509
28 4 1 8
a=
1.5090

Task 4
Ra=round(a)
A=log(39)
Ra =
A= 2
3.6636

Ca=ceil(a)
B=log(55)
Ca =
B= 2
4.0073

Fa=floor(a)
C=log(2)
Fa =
C= 1
0.6931

b=0.0062
b=
Task 5: 0.0062
a=exp(23)
a= Rb=round(b)
9.7448e+09
Rb =
0
b=exp(-7)
b=
Cb=ceil(b)
9.1188e-04
Cb =
1 Documentation for exp
Other uses of exp

Fb=floor(b)
help log
Fb =
0 log Natural logarithm.
log(X) is the natural logarithm of the
elements of X.
Task 7: Complex results are produced if X is not
positive.
help ceil
ceil Round towards plus infinity. See also log1p, log2, log10, exp, logm,
ceil(X) rounds the elements of X to the reallog.
nearest integers
towards infinity. Documentation for log
Other uses of log
See also floor, round, fix.

Documentation for ceil Task 8:


Other uses of ceil
A=[1 2 8;6 3 4;7 5 2]
A=
help floor 1 2 8
floor Round towards minus infinity. 6 3 4
floor(X) rounds the elements of X to the 7 5 2
nearest integers
towards minus infinity.
B=A+2
See also round, ceil, fix.
B=
3 4 10
Documentation for floor
8 5 6
Other uses of floor
9 7 4

help exp
exp Exponential.
exp(X) is the exponential of the
elements of X, e to the X.
For complex Z=X+i*Y, exp(Z) =
exp(X)*(COS(Y)+i*SIN(Y)).

See also expm1, log, log10, expm,


expint.
Lab #02

OBJECT: To understand the fundamentals and commands of


MATLAB.
Task 1:

You might also like