matlab 求已知信号 f(t)=3cos(35πt) , 对f(t)以50Hz的采样频率进行采样,求采样信号f_sam(t),并绘制出其波形(stem函数)信号f_sam(t)的DTFT与DFT
时间: 2023-11-12 22:08:04 浏览: 219
利用MATLAB实现信号DFT的计算
5星 · 资源好评率100%
根据采样定理,采样频率应该大于信号的最高频率,即采样频率应该大于2*35π=70π Hz。因此,50Hz的采样频率可以满足要求。
采样周期为T=1/50=0.02秒,采样信号为:
f_sam(t) = f(t) * s(t)
= 3cos(35πt) * δ(t) + 3cos(35π(t-0.02)) * δ(t-0.02) + 3cos(35π(t-0.04)) * δ(t-0.04) + ...
其中,δ(t)表示单位冲击函数。
绘制其波形:
t = 0:0.0001:0.2;
f = 3*cos(35*pi*t);
stem(t,f,'Marker','none','LineWidth',2);
hold on;
stem(t(1:50:end),f(1:50:end),'r','Marker','none','LineWidth',2);
xlabel('t');
ylabel('f(t)');
title('Signal and Sampled Signal');
采样信号的DTFT和DFT分别为:
DTFT:
F_sam(ω) = F(ω) * S(ω)
= 1/2π * ∫[0,2π] 3cos(35πt) * (δ(t) + e^(-jωt)δ(t-0.02) + e^(-j2ωt)δ(t-0.04) + ...) dt
= 1/2π * (3 + e^(-jω0.02) * 3 + e^(-j2ω0.04) * 3 + ...)
= 1/2π * (3 / (1 - e^(-jω0.02)) + e^(-jω0.02) * 3 / (1 - e^(-jω0.02)) + e^(-j2ω0.04) * 3 / (1 - e^(-jω0.02)) + ...)
= (1/π) * (3 / (1 - 2cos(35π*0.02) * e^(-jω) + e^(-j2ω)) + 3 / (1 - 2cos(35π*0.02-ω) + e^(-j2ω)) + 3 / (1 - 2cos(35π*0.02-2ω) + e^(-j2ω)) + ...)
DFT:
由于采样频率为50Hz,每个采样周期包含50个采样点,因此采样信号的DFT为:
F_sam[k] = (1/N) * Σ[n=0,N-1] f_sam[n] * e^(-j2πkn/N)
其中,N=50,k=0,1,2,...,N-1。
MATLAB代码实现:
% DTFT
w = -pi:0.01:pi;
Fs = 50;
T = 1/Fs;
F = @(t) 3*cos(35*pi*t);
S = @(t) sum(dirac(t-n*T) for n=0:20);
F_sam = @(w) (1/pi) * sum(3./(1-2*cos(35*pi*T)*exp(-1j*w*T*(0:N-1)')) .* exp(-1j*w*T*(0:N-1)*k) for k=0:20);
figure;
plot(w, abs(F_sam(w)), 'LineWidth', 2);
xlabel('\omega');
ylabel('|F_{sam}(\omega)|');
title('DTFT of Sampled Signal');
% DFT
N = 50;
n = 0:N-1;
k = 0:N-1;
f_sam = F(n*T) .* S(n*T);
F_sam_DFT = (1/N) * sum(f_sam .* exp(-1j*2*pi/N*n'*k), 1);
figure;
stem(k, abs(F_sam_DFT), 'Marker', 'none', 'LineWidth', 2);
xlabel('k');
ylabel('|F_{sam}[k]|');
title('DFT of Sampled Signal');
阅读全文