Você está na página 1de 10

EXPERIMENT NO 1

OBJECTIVE: To understand and make MATLAB program’s using proper syntax and
its various applications in Signal & Systems and Digital Processing.

RESOURCE REQUIRED: mat lab software

THEORY:

In the signals and systems lab we were told how to use mat lab. We were taught
how to make functions in the M file and use those functions in the code. In
the first lab class we were taught different operations on matrices by using different
in build mat lab operations. The name MATLAB stands for Matriz Laboratory and
is a high-level interactive software package for scientific and engineering numeric
computation. It integrates numerical analysis, matrix computation, signal
processing and graphics into an easy-to-use environment where problems and
solutions are expressed just as they are written mathematically - without
traditional programming.

Programming constructs used:

1) for
2) if
3) Roots()
4) plot()
5) linspace()
6) line()

Post Lab exercise :

Q1. Plot the functions x and 2 on the same axes and determine how many times these
4 x

graphs intersect.

Source code:

d = linspace(-1.5,1.5,15);

c = d.^4;

a = 2.^d;

plot(d,c,d,a)

xlabel('x')

ylabel('x^4,2^x')
Figure:

4
x 4,2x

0
-1.5 -1 -0.5 0 0.5 1 1.5
x

Q2: Use a nested for loop to calculate the number of seconds in a week.
Source code:

t=0

for i=1:7;

for j=1:24;

for k=1:60;

for l=1:60

t=t+1;

end

end

end

end

OUTPUT

t=

604800

Q3: Plot the given figure:

Source code:
x = [0 0];
y = [0 5];

line(x,y)

hold on

line([0 2.5],[2.5,5])

line([2.5 5],[5 2.5])

line([0 10],[2.5 2.5])

line([5 5],[2.5 0.5])

line([5 7.5],[0.5 0.5])

line([7.5 7.5],[0.5 3.75])

line([10 10],[2.5 3.75])

q = linspace(0,6.28,40);
x = 1.25*cos(q) + 8.75;
y = 1.25*sin(q) + 3.75;
plot(x,y)

4
.5

3
.5

2
.5

1
.5

0
.5

0
0 1 2 3 4 5 6 7 8 9 1
0
Q4: Plot a semi-circle of given radius.

Source code:

q = linspace(0, 3.146,20);

x = (5*cos(q)) + 5;

y = (5*sin(q));

plot(x,y,x,0,'-')

xlabel('x = (5*cos(q)) + 5 ')

ylabel('y = (5*sin(q)')

Figure:
5

3
y = (5*sin(q)

-1
0 1 2 3 4 5 6 7 8 9 10
x = (5*cos(q)) + 5

Q5 :Find the roots of the following polynomial:


y = x – 3x – 6x +8:
3 2

Source code:

y=[1 -3 -6 8]

roots(y)

Result:

y=

1 -3 -6 8

ans =

4.0000

-2.0000

1.0000
Q6: Create a M-by-N array of random numbers. Move through the array element by
element and set any value that is less than 0.3 to 0 and any value greater than or equal
to 0.3 to 1.

Source code:

m = 4;

n = 5;

y = rand(m,n)

for j=1:m

for i=1:n

if y(j,i)< 0.3

y(j,i) = 0;

else

y(j,i) = 1;

end

end

end

Result:-

y=

0.9501 0.8913 0.8214 0.9218 0.9355

0.2311 0.7621 0.4447 0.7382 0.9169

0.6068 0.4565 0.6154 0.1763 0.4103

0.4860 0.0185 0.7919 0.4057 0.8936


y=

1 1 1 1 1

0 1 1 1 1

1 1 1 0 1

1 0 1 1 1

LEARNING OUTCOME:

We learnt simple matlab codes. We learnt how to plot some simple shapes like
triangle and circle.

We also learnt how to find roots of a given equation using matlab.

INDEX
S.N EXPERIMENT DATE SIGNATURE
O
SIGNALS AND
SYSTEMS
LAB
(10B17E307)

SUBMITTED TO:
MRS. JUHI

SUBMITTED BY:

09104685 –
ANUPAM SINHA
09104677 -
SAURABH GUPTA

(BA
TCH B-7)

Você também pode gostar