Experiment No 1: OBJECTIVE: To Understand and Make MATLAB Program's Using Proper Syntax and
Experiment No 1: OBJECTIVE: To Understand and Make MATLAB Program's Using Proper Syntax and
OBJECTIVE: To understand and make MATLAB program’s using proper syntax and
its various applications in Signal & Systems and Digital Processing.
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.
1) for
2) if
3) Roots()
4) plot()
5) linspace()
6) line()
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
Source code:
x = [0 0];
y = [0 5];
line(x,y)
hold on
line([0 2.5],[2.5,5])
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,'-')
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
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=
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.
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)