You are on page 1of 9

Islamic University of Technology

Department of Electrical and Electronic Engineering (EEE)

Course code: EEE 4602


Course name: Signals And Systems Lab
Experiment number: 01

Name: Umama Kamrul Saifa


ID: 180021334
Section: C2
Department: EEE
Name: Umama Kamrul Saifa

ID: 180021334

%task 1

x = ones(10); %generates a 10*10 matrix with all the elements as 1


x(1,:)=cumsum(x(1,:),2); %cumulative sum operation on all the elements of first row
x = cumsum(x); %cumulative sum operation on all the elements of all the columns
x-1 %to mke the starting from zero

ans = 10×10
0 1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9 10
2 3 4 5 6 7 8 9 10 11
3 4 5 6 7 8 9 10 11 12
4 5 6 7 8 9 10 11 12 13
5 6 7 8 9 10 11 12 13 14
6 7 8 9 10 11 12 13 14 15
7 8 9 10 11 12 13 14 15 16
8 9 10 11 12 13 14 15 16 17
9 10 11 12 13 14 15 16 17 18

%task 2

x = 10*rand(5) % a 5*5 matrix with all the random values from 0 to 10

x = 5×5
5.8299 8.2438 1.0777 5.9436 1.7877
2.5181 9.8266 9.0631 0.2251 4.2289
2.9044 7.3025 8.7965 4.2526 0.9423
6.1709 3.4388 8.1776 3.1272 5.9852
2.6528 5.8407 2.6073 1.6148 4.7092

x(3,:) = rand(1,5); %all the 3rd row elements replaced with 5 random numbers from 0 to 1
x

x = 5×5
5.8299 8.2438 1.0777 5.9436 1.7877
2.5181 9.8266 9.0631 0.2251 4.2289
0.6959 0.6999 0.6385 0.0336 0.0688
6.1709 3.4388 8.1776 3.1272 5.9852
2.6528 5.8407 2.6073 1.6148 4.7092

v=num2cell(randi(4,1,2)); % a random 1*2 cell generated with values upto 4 as the matrix siz
[r,c] = v{:}; % random row and column number is collected from v cell
y = x(r:r+1,c:c+1) % random 2*2 matrix generated

y = 2×2
9.0631 0.2251
0.6385 0.0336

inv(y) %for the inverse of the sub-matrix

ans = 2×2
0.2090 -1.4000
-3.9709 56.3609

1
%task 3

f = 34; %frequency taken as my id value


t = 0 : 0.005 : 2; %time from 0 to 2s with 0.005 interval
F = @(x,y) 0.5*(-1j)*(exp(1j*y*x)- exp(-1j*y*x)); %eulers identity function
s = F(t,2*pi*f); %the function value with t and w=2*pi*f
plot(t,s) % plotting in the graph
title('A Sine wave using Eulers Identity')
xlabel(' Time (s) ')
ylabel('Amplitude')

%task 4

f = 334;
t = 0 : 0.001 : 1;

F = @(x,y) sin(2*pi*y*x);
s = zeros(1,length(t));

for i = 1 : 8
s = s + F(t,f+2*(i-1));
figure(1)
subplot(8,1,i)
plot(t,s)
end

2
3
%task 6

x = sin(linspace(0,10*pi,100));
p = x(x>0); %stores the greater than 0 numbers of x in p
length(p)

ans = 49

%task 7

a = 5;
f = 20;
d = 0.6;
T = 1/f;
t = 0 : 0.0001 : 1;

F = @(x,y,z,w) w*((mod(x,y)<=z*y)-(mod(x,y)>z*y));

s = F(t,T,d,a);
plot(t,s,'linewidth',3)
grid on
axis([0 0.3 -10 10])

%task 8

1
a = 5;
f = 20;
w = 2*pi*f;
t = 0 : 0.0001 : 1;

s = a*sawtooth(w*t);
plot(t,s,'linewidth',3)
grid on
axis([0 0.3 -10 10])

%task 9

t = -1 : 0.001 : 4;

f1 = @(x,a,b,c,d) - x.*((x>a)&(x<=b)) + (-3+2*x).*((x>b)&(x<=c))+ (3-x).*((x>c)&(x<=d));

f2 = @(x,a,b,c) x.*((x>a)&(x<=b)) + (6-2*x).*((x>b)&(x<=c));

s1 = f1(t,0,1,2,3);
s2 = f2(t,0,2,3);

2
figure(1)
plot(t,s1,'linewidth',3)
grid on
axis([-1 4 -2 2])

figure(2)
plot(t,s2,'linewidth',3)
grid on
axis([-1 4 -2 3])

3
4

You might also like