📄 parti.m
字号:
clear all %Clear all variables in memory
Trep = 1e-6; % Define the time interval that will make signals look continuous
t1 = [0:Trep:.01]; % Define a vector representing time
f_tone1=1000; % Set frequency to 1000Hz
Tsmp = 1e-4; % Sample interval?
%Part I a)defines a vector representing the input continuous time signal
xt = cos(2*pi*f_tone1*t1);
%Part I b)Plots the input continuous time signal
subplot(6,1,1), plot(xt), title('Continuous time Signal: x(t)');
%Part I c)Calculates and plots the Fourier Transform spectrum of x(t)
xt_FT = fft(xt);
xt_FT_shift = fftshift(xt_FT);
f_axis=linspace(-1/Trep/2,1/Trep/2,length(xt_FT));
subplot(6,1,2), plot(f_axis,abs(xt_FT_shift)), axis([-1500, 1500,0,5000]), title('Frequency Spectrum - Fourier Transform of X(JW)');
%Part I d)Defines a second vector representing the impulse train p(t)
samplingInterval = Tsmp/Trep;
p = zeros(1,length(t1));
p(1:samplingInterval:end) = 1;
%Part I e)Ideally samples the input signal x(t) to get xs(t)
xS = xt.*p;
subplot(6,1,3), plot(t1,xS), title('Xs(t): sampled x(t)');
%Part I f)Calculates and plots Xs(jw), the Fourier Transform spectrum of
%the sampled version of x(t)
xS_FT = fft(xS);
xS_FT_Shift = fftshift(xS_FT);
xS_FT_Shift(find(abs(xS_FT_Shift)<1.5))=0;
subplot(6,1,4), plot(f_axis,xS_FT_Shift), axis([-20000, 20000,0,60]), title('FFT Spectrum: Xs(JW)');
%Part I g)Ideally filters the sampled signal Xs(t) with an ideal low-pass
% filter defined
xsFilter = xS_FT_Shift;
for n=1:length(f_axis)
xsFilter(n) = lowPassFilter( xS_FT_Shift(n), Tsmp, f_axis(n) * 2 * pi );
end
%Part I h)Plots the resulting spectrum of the reconstructed signal Xr(jw)
xsFilter_FT = fft(xsFilter);
xsFilter_FT_Shift = fftshift(xsFilter_FT);
subplot(6,1,5), plot(f_axis,abs(xsFilter)), axis([-1500, 1500,0,.01]), title('Reconstruction of Signal : Xr(JW)');
%Part I i)Calculate the reconstructed signal Xr(t) by computing the
% inverse Fourier Transform of Xr(jw)
xs_IFFT = invFT(xsFilter);
subplot(6,1,6),
plot(t1,xs_IFFT), title('Comparison of Signals: x(t) AND Xr(jw)');
hold on;
Scaled_out=max(xs_IFFT)/max(xt)*xt;
plot(t1,Scaled_out);
hold off;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -