0% found this document useful (0 votes)
19 views27 pages

DLS Programming Practical Exercises

these are matlab programs in c

Uploaded by

iucgajjar5386
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views27 pages

DLS Programming Practical Exercises

these are matlab programs in c

Uploaded by

iucgajjar5386
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Practical 1

Quiz :
v1 = [1 2 3 4 5 6 7 8 9 0]
v2 = [0.3 1.2 0.5 2.1 0.1 0.4 3.6 4.2 1.7 0.9 ]
v3 = [4 4 4 4 3 3 2 2 2 1 ]

(a)calculate respectively the sum of all the elements in vector v1 , v2 and v3

W = v1 + v2 + v3
W = [5.3 7.2 7.5 10.1 8.1 9.4 12.6 14.2 12.7 1.9 ]

(b)how to get the value of the 5th elements of each vector ?

K = [ v1 (5) v2(5) v3 (5) ]


K = [5 0.1 3]

(c)what happens if we execute the command v1 (0) and v1 (11)? Remember that if 0
vector has ‘N’ element ; their subscripts are from 1 to N

S = [v1(0) v1(11)]
Array indicates must be positive integers or logical value.

(d)generate a new vector v4 from v2 consisting of the first five element of v4.

V4 = [v2(1) v2(2) v2(3) v2 (4) v2(5) ]


= [0.3 1.2 0.5 0.1 2.1 0.1 ]
(e) generate a new vector v5 from v2 consisting of the last five element of v2

V5 = [v2(6) v2(7) v2(8) v2(9) v2(10)]


= [ 0.4 3.6 4.2 1.7 0.9 ]

(f) generate a new vector v6 from v2 with its 6th element omitted.
V6 = [v2(1) v2(2) v2(3) v2(4) v2(5) v2(6) v2(7) v2(8) v2(9) v2(10)]
= [0.3 1.2 0.5 2.1 0.1 3.6 4.2 1.7 12.9 ]

(h) generate a new vector v8 from v2 whose elements are 1st , 3rd ,7th and 9th elements
of v2 ?
V8 = [v2(1) v2(3) v2(7) v2(9)]
= [0.3 0.5 3.6 1.7 ]

What are the results of


(i) 9-v1 = [ 8 7 6 5 4 3 2 1 0 9]
(ii) V1*5 = [5 10 15 20 25 30 35 40 45 0]
(iii) V1+v2 = 1.3 3.2 3.5 6.1 5.1 6.4 10.6 12.2 10.7 0.9 ]
(iv) V1-v3 = -3 -2 -1 0 2 3 5 6 7 -1]
(v) V1*v2 = [0.3 2.4 1.5 8.4 0.5 0.4 25.2 33.6 15.3 ]
(vi) V1*V2 =
(vii) V1^2 = [1 4 9 16 25 36 49 64 81 0 ]
(viii) V1^V3 = [1 16 81 256 125 49 84 81 0]
(ix) V1 ==V3 [0 0 0 1 0 0 0 0 0 0]
(x) V1>6 = [0 0 0 0 0 0 1 1 1 0]
(xi) V1>v3 = [0 0 0 0 1 1 1 1 1 0 ]
(xii) V3-(V1>2) = [4 4 3 3 2 2 1 1 1 1 ]
(xiii) V2>2) AND V1 <6) = [0 0 1 1 1 0 0 0 0 0 ]
(xiv) (V2>2)1 (V1<6) = [ 1 1 1 1 1 1 1 1 1 1 1 1 1 ]
(xv) ANY (V1) = 1
(xvi) ALL (V1) = 0
Practical 2

1) Sinusoidal Signal Generation :


Consider generating 64 samples of a sinusoidal signal of frequency 1KHz, with a sampling
frequency of 8KHz.A sampled sinusoid may be written as
Where f is the signal frequency, fs is the sampling frequency,  is the phase and A
Is the amplitude of the signal. The program and its output is shown below
2) Generate the following signals
(i) 64 Samples of a cosine wave of frequency 25Hz , sampling frequency 400Hz,amplitude of
1.5 volts and phase =0.
(ii) The same signal as in (i) but with a phase angle of/4 (i.e. 45 degree).
Practical 3
Write a program to generate following signals
Where u(n)/u(t) is unit step signal
r(n)/r(t) is ramp signal
d(n)/d(t) is impulse signal

1.x(t)= u(-t+1)
2. x(t)=3r(t-1)
3. x(t)=u(n+2)-u(n-3)
4. x(n)=x1(n)+x2(n)where x1(n)={1,3,2,1},x2(n)={1,-2,3,2}
5. x(t)=r(t)-2r(t-1)+r(t-2)
6. x(n)=2d(n+2)-2d(n-4), -5≤ n ≤5.
7. X(n)={1,2,3,4,5,6,7,6,5,4,2,1} determine and plot the following sequence
a. x1(n)=2x(n-5)-3x(n+4)
b. x2(n)=x(3-n)+x(n)x(n-2)
8. Sketch the following signals:
(a) x(n)=u(n+2) u(-n+3)

(b) x(n) = u(n+4) – u(n-2)


Practical 4
1) Find whether the signal is even or odd.
(𝑡) = sin 3𝑡

2) Weather below signal is causal or anti-causal or non-causal?


x(t)=e4tu(t−3)

3) Examine whether the following signals is periodic or not? If periodic then determine the
fundamental period of the signal.
(𝑡) = sin 20𝜋𝑡

4) Calculate the following signals energies


1. x(t)= e j(2t+Π/4)

2. x(t)= cos(t)
3. x(t)= cos(Π/4 n)

Practical 5
1) Find whether the given systems are invertible or non-invertible
A system is invertible if, for each output y(t)y(t)y(t), there is a unique input x(t)x(t)x(t).
Invertibility means you can uniquely determine x(t)x(t)x(t) from y(t)y(t)y(t).

A. 𝑦(𝑡) = 3𝑥(𝑡)
This is invertible because we can uniquely determine

B. 𝑦(𝑡) = 5 + 𝑥(𝑡)
This is invertible because we can uniquely determine

C. 𝑦(𝑡) = 2𝑥2(𝑡)
This is non-invertible because for a given y(t)y(t)y(t), there are two possible values for x(t).

2) Determine whether the following systems are time-invariant or time-variant


3) Check whether the given systems are linear or non-linear systems
Practical 6

1) Perform convolution between the following signals


x(n)=[1 -1 4 ], h(n) = [ -1 2 -3 1]
2) Perform convolution between Two periodic sequences
x1(t)=e-3t{u(t)-u(t-2)} , x2(t)= e -3t for 0 ≤ t ≤ 2
3) Find the linear convolution of x(n)=[7 5 4 0] and h(n)=[0 3 6 2 9]

You might also like