% (a)
n_from = 0;
n_to = 999;

n = [n_from:n_to];

w_col = [0.9273 1.0247 1.1328];
w_row = [0.5346 0.5906 0.6535 0.7217];

%  1 2 3
%1 1 2 3
%2 4 5 6
%3 7 8 9
%4   0
w0 = [w_row(4) w_col(2)];
w1 = [w_row(1) w_col(1)];
w2 = [w_row(1) w_col(2)];
w3 = [w_row(1) w_col(3)];
w4 = [w_row(2) w_col(1)];
w5 = [w_row(2) w_col(2)];
w6 = [w_row(2) w_col(3)];
w7 = [w_row(3) w_col(1)];
w8 = [w_row(3) w_col(2)];
w9 = [w_row(3) w_col(3)];

d0 = sin(n*w0(1)) + sin(n*w0(2));
d1 = sin(n*w1(1)) + sin(n*w1(2));
d2 = sin(n*w2(1)) + sin(n*w2(2));
d3 = sin(n*w3(1)) + sin(n*w3(2));
d4 = sin(n*w4(1)) + sin(n*w4(2));
d5 = sin(n*w5(1)) + sin(n*w5(2));
d6 = sin(n*w6(1)) + sin(n*w6(2));
d7 = sin(n*w7(1)) + sin(n*w7(2));
d8 = sin(n*w8(1)) + sin(n*w8(2));
d9 = sin(n*w9(1)) + sin(n*w9(2));

% (b)
D2 = fft(d2, 2048);
D9 = fft(d9, 2048);
k = [0:2047];
omega = 2*pi*k/2048;
figure;
plot(omega, abs(D2));
xlabel('w'); ylabel('D2');
axis([0.5 1.25 0 600]);
% peaks are at 0.55 and 1.05
figure;
plot(omega, abs(D9));
xlabel('w'); ylabel('D9');
axis([0.5 1.25 0 600]);
% peaks are at 0.65 and 1.15

% (c)
space = zeros(1,500);
% my phone is 225-7326
phone = [d2 space d2 space d5 space d7 space d3 space d2 space d6];
