%%%%%%%%%%%%%%%%
% PROBLEM 27 %
%%%%%%%%%%%%%%%%

% CREATE 1/120 FUNCTION
i=0;
timeInterval=1/120;

sample=0:timeInterval:400;

for j=0:timeInterval:400
i++;
signal(i)= 3*cos(20*pi*t) - 2*sin(30*pi*t);
end

% SHOW PLOT
figure('Name', '27a) 1/120 Second Sampling'), plot(sample, signal);

%%%%%%%%%%%%%%
%%%%%%%%%%%%%%
%%%%%%%%%%%%%%

% CREATE 1/60 FUNCTION
i=0;
timeInterval=1/60;

sample=0:timeInterval:400;

for j=0:timeInterval:400
i++;
signal(i)= 3*cos(20*pi*t) - 2*sin(30*pi*t);
end

% SHOW PLOT
figure('Name', '27b) 1/60 Second Sampling'), plot(sample, signal);

%%%%%%%%%%%%%%
%%%%%%%%%%%%%%
%%%%%%%%%%%%%%

% CREATE 1/30 FUNCTION
i=0;
timeInterval=1/30;

sample=0:timeInterval:400;

for j=0:timeInterval:400
i++;
signal(i)= 3*cos(20*pi*t) - 2*sin(30*pi*t);
end

% SHOW PLOT
figure('Name', '27c) 1/30 Second Sampling'), plot(sample, signal);

%%%%%%%%%%%%%%
%%%%%%%%%%%%%%
%%%%%%%%%%%%%%

% CREATE 1/15 FUNCTION
i=0;
timeInterval=1/15;

sample=0:timeInterval:400;

for j=0:timeInterval:400
i++;
signal(i)= 3*cos(20*pi*t) - 2*sin(30*pi*t);
end

% SHOW PLOT
figure('Name', '27d) 1/15 Second Sampling'), plot(sample, signal);

%%%%%%%%%%%%%%%%
% PROBLEM 45 %
%%%%%%%%%%%%%%%%

% CREATE 256 RANDOM DATA POINTS IN VECTOR x
x=randn(256, 1);

% FIND DFT OF VALUES IN x AND STORE IN X
X=fft(x);

% CREATE DUPE OF X CALLED Xlpf
Xlpf=X;

% CHANGE ALL VALUES IN Xlpf TO 0 EXCEPT FOR FIRST AND LAST 8
for i=0:1:256
Xlpf(i)=0;

% STORE REAL PART OF INVERSE OF Xlpf INTO xlpf
xlpf=real(ifft(Xlpf));

% CREATE SET OF SAMPLE TIMES FROM 0 TO 255
t=0:1:255;

% PLOT x AND xlpf WITH RESPECT TO t
figure('Name', 'Problem 24'), plot(t, x);
hold on;
plot(t, xlpf);
hold off;