Você está na página 1de 2

Birla Institute of Technology and Science(BITS), Pilani

Department Of E.C.E
Course: B.S Assignment-1 Course ID: ZC164
Due Date : 30-Oct-2014 Computer Programming in MATLAB Max. Marks: 20
Note-1: Assume all the relevant inputs if necessary.
Note-2: All relevant assumptions to be dened completely and clearly.
Note-3: Each answer should contain complete MATLAB code.
Note-4: The MATLAB code should take care of most of the trivial error conditions that might occur.
Note-5: A
mn
denotes a matrix of m-rows and n-columns.
Note-6: For 1r m, A
r
denotes the r-th row of A.
Note-7: For 1cn, A
c
denotes the c-th column of A.
1.
1 a1 = 0; c1 = 1;
2 while c1
3
4 a1 = a1 + 1;
5
6 end;
Find the discrepancy in this MATLAB code.
[01-Marks]
2. For an array a = [1 2 3; 8 9 10; 17 23 11; 9 7 6]; nd the following
(a) a(5)
(b) a(9)
(c) a(2,1)
(d) a(3,3)
[(
1
4
)*4-Marks]
3. Compute the A
1
of A
22

_
a
11
a
12
a
21
a
22
_
using the expression A
1
=
1

_
a
22
a
12
a
21
a
11
_
where (a
11
a
22

a
12
a
21
).
[01-Marks]
4. (a) Plot the function y(t)=
_
4+9t
1
16t
2
_
for 0.6t 0.5 using 20 distinct values of t.
(b) On the same plot identify the values of y(t) for t
_
1/2, 4/9, 0, 1/2
_
using the stem function.
[(2+1)-Marks]
Page 1 of 2
5. With
_
t
1
=2, t
2
=3, t
3
=5
_
, construct a matrix A
_
_
1 t
1
t
2
1
t
3
1
1 t
2
t
2
2
t
3
2
1 t
3
t
2
3
t
3
3
_
_
using a vector u
_
_
t
1
t
2
t
3
_
_
.
[02-Marks]
6. The distance between two points
_
x
1
, y
1
, z
1
_
and
_
x
2
, y
2
, z
2
_
is given by
d=
_
(x
1
x
2
)
2
+(y
1
y
2
)
2
+(z
1
z
2
)
2
. Compute d using column vectors and builtin matlab functions.
[02-Marks]
7. With inputs as
_
R, L, C, V
A
,
_
, compute V
R
=
R
_
R
2
+
_
L
1
C
_
2
V
A
[02-Marks]
8. Let A
42
=
_

_
15 4
3 1
10 78
9 101
_

_
. The rows of A are to be sorted such that rst column of the matrix B
42
has values
in ascending order so that B
42
=
_

_
9 101
3 1
10 78
15 4
_

_
. Obtain B from A.
[02-Marks]
9. Consider A
33
=
_
_
3 4 7
10 17 20
34 19 17
_
_
, B
33
=
_
_
23 24 72
11 27 21
34 9 71
_
_
. Obtain a matrix C
36
such that C
(2i1)
=A
i
and C
(2i)
=B
i
with 1 i 3. Here odd column numbers of C are copied from A and the even column
numbers are from B.
[02-Marks]
10. Consider a function sinc()
_
_
_
1, =0
sin()

, =0
.
(a) Obtain the samples of the function sinc() for 2 2 with 32 data points generated by using
MATLABs try and catch statements.
(b) plot the above sampled values using stem function.
[(2+2)-Marks]
Page 2 of 2

Você também pode gostar