📄 incfreq2.m
字号:
% mar 6, 2007: to plot Fourier coeffs vs freq for decreasing freq-cutoff
% this is for a rectangular shape of width 1, sinc result also included
%
clear; hold off;
tau = 1; % width of rectangular pulse
ftab = [32, 16, 8, 4]; % table of F values: F is the sampling rate
coltab1 = ['r*'; 'y*'; 'g*'; 'c*'; 'm*'];
coltab2 = ['r'; 'y'; 'g'; 'c'; 'm'];
T = 32; % time period
fmax = 8; % max freq to be plotted
for count = 1: length(ftab)
F = ftab(count);
N = round(T*F); % base of dft
v(1:N) = zeros(1, N); % clear out v to allow for summing if overlap
for k = (-N/2) : (-N/2) + N -1
abst = abs(k/F);
kp = 1 + mod(k, N);
if abst < tau/2
v(kp) = v(kp) + 1;
end % if
end % for
%%subplot(2,2, count); plot(v);
vv = fft(v, N)/F;
for n=0:round(T*fmax)
f(1+n) = n/T;
if n==0, ss(1+n)=1; else, ss(1+n) = sin(pi*n/T)/(pi*n/T); end
end
l = min([length(f), length(vv)]);
%%plot(f(1:l),(.1*(count-1))*ones(1, l), coltab2(count, :)); hold on;
%%plot(f(1:l), .1*(count-1) + real(vv(1:l)), coltab2(count,:)); hold on;
plot(f(1:l), real(vv(1:l)), coltab2(count,:)); hold on;
clear f; clear v; clear vv;
end
for n=0:round(T*fmax)
f(1+n) = n/T;
if n==0, ss(1+n)=1; else, ss(1+n) = sin(pi*n/T)/(pi*n/T); end
end
l = min([length(f), length(ss)]);
plot(f(1:l), ss(1:l), 'w');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -