Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

EEE 244

PROBLEM SET 1- SOLUTIONS

1.
% Problem 1(a)
clear
t=0:0.01:5;
x=5*cos(2*pi*15*t+0.25*pi);
subplot(2,1,1);
plot(t,x);
xlabel(t);
ylabel(x(t));
title(Problem 1a);
% Problem 1(b)
x=5*cos(2*pi*15*t-0.5*pi) + 5*cos(2*pi*10*t+0.3*pi);
subplot(2,1,2);
plot(t,x);
xlabel(t);
ylabel(x(t));
title(Problem 1b);
Problem 1a

x(t)

-5

0.5

1.5

0.5

1.5

10

2.5
3
t
Problem 1b

3.5

4.5

3.5

4.5

x(t)

5
0
-5
-10

2.5
t

2.
% Problem 2(a)
clear
n=-5:5;
x=0.5.^abs(n);
subplot(2,1,1);
stem(n,x);
xlabel(n);
ylabel(x(n));
title(Problem 2a);
% Problem 2(b)
w=1.5*pi;
x=5 *cos(w*n + 0.3*pi);
subplot(2,1,2);
stem(n,x);
xlabel(n);
ylabel(x(n));
title(Problem 2b);
Problem 2a

x(n)

0.5

0
-5

-4

-3

-2

-1

-4

-3

-2

-1

x(n)

0
1
n
Problem 2b

-5
-5

0
n

3.
clear
y = imread('ngc6543a.jpg');
imshow(y);
ymin=min(min(min(y)))
ymax=max(max(max(y)))
ysize=size(y)
number_of_pixels=ysize(1)*ysize(2)

ymin=
0
ymax=
255
ysize=
6506003
number_of_pixels=
390000
4.
(i) The command y=a*b is a matrix multiplication, and the requirement is that the number
of rows of matrix a should be equal to the number of columns of matrix b.
The command a.*b is an element by element product, and the requirement is that the size
of matrics a and b should be exactly the same, i.e. the number of rows of matrix a should
be equal to the number of rows of matrix b, and number of columns of matrix a should
be equal to the number of columns of matrix b.
(ii)
% Matlab program for matrix multiplication
clear
a=[1 2 3];
b=[4 5 6];

c=a*b;
d=a.*b;
(iii)
The command c=a.*b is fine, since both matrices are identical in size; however, the
command c=a*b gives an error, since the number of rows of a is not equal to the number
of columns of b. The corrected command would c=a*b.

You might also like