In: Electrical Engineering
use matlab
y(t)=10*(cos(2*pi*500*t)+cos(2*pi*1000*t)+ cos(2*pi*1500*t)).
e) Down sample y(t) by a factor of 6. Sketch the Fourier transform with appropriate frequency axis. Check if all frequency components are correct?
Up-sample the time-domain signal obtained in e) by a factor of 6. Use appropriate filter for interpolation. Sketch the Fourier transform of the up-sampled and filtered signal. Does the resulting signal show all frequency components of the original signal y(t)?
Sorry for the inconvenience caused to you. Pls. find below the Matlab program as per the given question:
clc
clear all
close all
%%
fs= 4000; %%(assumed)
Ts= 1/fs;
t=0:Ts:5e-2;
f1=500;
f2=1000;
f3=1500;
y= 5*sin(2*pi*f1*t)+ 5*sin(2*pi*f2*t)+ sin(2*pi*f3*t);
figure(1);
plot(t,y);
title('Input signal');
%% Fourier Transform of original signal
N=length(y);
N1=2.^nextpow2(N);
fy=fft(y,N1);
fy=fy(1:N1/2);
K=(0:N1/2-1)/(N1/fs);
figure(2);
plot(K,abs(fy/max(fy)));
title('Magnitude spectrum of original signal');
%% Downsample by 6
y1= 5*sin(2*pi*f1*t*6)+ 5*sin(2*pi*f2*t*6)+ sin(2*pi*f3*t*6);
figure(3);
plot(1:6:6*length(y1),y1);
title('Downsampled signal by 6');
%% Fourier Transform of Downsampled signal
N=length(y1);
N1=2.^nextpow2(N);
fy=fft(y1,N1);
fy=fy(1:N1/2);
K=(0:N1/2-1)/(N1/fs);
figure(4);
plot(K,abs(fy/max(fy)));
title('Magnitude spectrum of Downsampled signal by 6');
%%
%%Upsampled by 6
y2= 5*sin(2*pi*f1*t/6)+ 5*sin(2*pi*f2*t/6)+ sin(2*pi*f3*t/6);
figure(5);
plot(1:6:6*length(y2),y2);
title('Upsampled signal by 6');
%% Fourier Transform of Upsampled signal
N=length(y2);
N1=2.^nextpow2(N);
fy=fft(y2,N1);
fy=fy(1:N1/2);
K=(0:N1/2-1)/(N1/fs);
figure(6);
plot(K,abs(fy/max(fy)));
title('Magnitude spectrum of Upsampled signal by 6');
%%
%%Interpolation Filter
upsampling = 6;
Ripple = 0.5;
h = intfilt(upsampling,2,Ripple);
b = fir1(40,Ripple);
%%rng('default')
x1 = filter(b,1,y2);
x2 = upsample(x1,upsampling);
y = filter(h,1,x2);
delay = mean(grpdelay(h));
y(1:delay) = [];
stem(1:upsampling:upsampling*length(x1),x1)
hold on
plot(y)
title(' Interpolated signal');