将a的每个元素重复 N 个,[ 1 3 4 5 7] ---> [ 1 1 1 1 3 3 3 3 4 4 4 4 5 5 5 5 7 7 7 7 ]
N = 10; a = [ 1 3 4 5 7]; %欲将a的每个元素重复 N 个 % 1、先将a整形为每个元素后加 N-1 个0 % 例如:c=[1 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 ...] % 2、再将c与b卷积 conv(c,b),取结果的前 N*M 个 b = ones(1,N); % 1、 M = length(a); c = zeros(N,M); c(1,:) = a; c = reshape(c,1,N*M); % 2、 out = conv(c,b); out = out(1:N*M);
等价于
out = rectpulse([1 3 5 ],10); % out = [1 1 1 1 1 1 1 1 1 1 3 3 3 3 3 3 3 3 3 3 5 5 5 5 5 5 5 5 5 5 ]
rectpulse(a,N);
理想低通滤波器
$$ H(f)={^{1, quad |f| leq 5/(2T_s)}_{0, quad others} $$
$$ H(f)=begin{cases} 1 & |f| leq 5/(2T_s) \ 0 & others end{cases} $$
则 h(t)=5*sinc(5*t/Ts)