昨天看信号突然想算算这个,结果发现不会算积分,网上学了一下,记录一下
最近通过对信号与系统的研究从信号角度进行更简单的解答
s i n c ( t ) = s i n ( π t ) / ( π t ) sinc(t) = sin(πt)/(πt) sinc(t)=sin(πt)/(πt)
傅里叶变换后的形式为:
u
[
(
w
+
1
)
/
p
i
)
]
−
u
[
(
w
−
1
)
/
p
i
)
]
u[(w+1)/pi)]-u[(w-1)/pi)]
u[(w+1)/pi)]−u[(w−1)/pi)]
2.Sa函数,又称采样函数,表达式为:
S
a
(
t
)
=
s
i
n
(
t
)
/
t
Sa(t)=sin(t)/t
Sa(t)=sin(t)/t
傅里叶变换后的形式为:
p
i
∗
[
u
(
w
+
1
)
−
u
(
w
−
1
)
]
pi*[u(w+1)-u(w-1)]
pi∗[u(w+1)−u(w−1)]
起始二者的区别只在于是否归一化。
仿真示例与代码:
clc; clear all; close all;
% Author: @IMMUNIZE
dt=0.01;
fs=1/dt;
t=-100:dt:100-dt
sinct=sin(pi*t)./(pi*t);
Sa = sin(t)./t;
subplot(4,1,1);
plot(t,sinct);
xlim([-8,8]);
title('sinct/t时域');
subplot(4,1,3);
plot(t,Sa);
xlim([-8,8]);
N=2^20*32;
sincf=fft(sinct,N);
Saf = fft(Sa,N);
f=-fs/2:fs/N:(fs/2-fs/N);
title('Sa/t时域');
subplot(4,1,2);
plot(f,fftshift(abs(sincf))/max(abs(sincf)))
axis([-10 10,0,1]);
title('sinct/t频域');
subplot(4,1,4);
plot(f,fftshift(abs(Saf))/max(abs(Saf)))
axis([-10 10,0,1]);
title('Sa/t频域');
绘制图形为:
另外请注意虽然频域上是个矩形,其作为滤波器的矩行系数为1,不可实现,另有,反推之其时域为非因果系统,而非因果系统在物理上同样是不可实现的,因此实际应用中我们都只能尽可能的逼近而做不到完全理想。如此即为数字滤波器的基本前置知识。
sinc
函数,其形式是
s
i
n
(
π
t
)
π
t
\displaystyle\frac{sin(\pi t)}{\pi t}
πtsin(πt),我们要在仿真中使用的是 Sa
函数,其形式是
s
i
n
(
t
)
t
\displaystyle\frac{sin(t)}{t}
tsin(t),因此 sa = sinc(t/pi)
。%% 打印出来sa函数
t = -20:0.001:20;
L = length(t);
x = sinc(t / pi);
plot(t,x,'LineWidth',3);
xlabel('t');ylabel('Amplitude'); title('Sa(t)')
fs = sinc(t/pi)
。%% matlab 完成Sa信号的采样和恢复
%% 取样(临界取样)
% 取样
figure(1);
wm = 1; %信号的最大频率
ws = 2 * wm; %信号的采样频率(根据奈奎斯特频率)
wc = 0.5 * ws;%滤波器的截止频率
Ts = 2*pi/ws;%采样间隔
N = 10;%时域采样点数
n = -N:N;
nTs = n * Ts;%采样数据的采样时间
fs = sinc(nTs/pi);%完成采样
subplot(311);
stem(nTs/pi,fs,'LineWidth',3);
xlabel("nTs");
ylabel("f(nTs)");
title("sa(t)的临界取样信号");
% 还原
Dt = 0.005;
t = -15:Dt:15;
fa = Ts*wc/pi * fs * sinc((wc/pi)*(ones(length(nTs),1)*t-nTs'*ones(1,length(t))));
subplot(312);
plot(t,fa,'LineWidth',3);
xlabel("t");
ylabel("f(t)");
title("由临界取样信号重构sa(t)");
% 展示误差
error = abs(fa-sinc(t/pi));
subplot(313);
plot(t,error,'LineWidth',3);
xlabel("t");
ylabel("error(t)");
title("重构信号与原信号的误差error(t)");
%% 取样(过取样)
% 取样
figure(2);
wm = 1; %信号的最大频率
ws = 4 * wm; %信号的采样频率(根据奈奎斯特频率)
wc = 0.5 * ws;%滤波器的截止频率
Ts = 2*pi/ws;%采样间隔
N = 20;%时域采样点数
n = -N:N;
nTs = n * Ts;%采样数据的采样时间
fs = sinc(nTs/pi);%完成采样
subplot(311);
stem(nTs/pi,fs,'LineWidth',3);
xlabel("nTs");
ylabel("f(nTs)");
title("sa(t)的过取样信号");
% 还原
Dt = 0.005;
t = -15:Dt:15;
fa = fs*Ts*wc/pi * sinc((wc/pi)*(ones(length(nTs),1)*t-nTs'*ones(1,length(t))));
subplot(312);
plot(t,fa,'LineWidth',3);
xlabel("t");
ylabel("f(t)");
title("由过取样信号重构sa(t)");
% 展示误差
error = abs(fa-sinc(t/pi));
subplot(313);
plot(t,error,'LineWidth',3);
xlabel("t");
ylabel("error(t)");
title("重构信号与原信号的误差error(t)");
%% 取样(欠取样)
% 取样
figure(3);
wm = 1; %信号的最大频率
ws = 1.5 * wm; %信号的采样频率(根据奈奎斯特频率)
wc = 0.5 * ws;%滤波器的截止频率
Ts = 2*pi/ws;%采样间隔
N = 7;%时域采样点数
n = -N:N;
nTs = n * Ts;%采样数据的采样时间
fs = sinc(nTs/pi);%完成采样
subplot(311);
stem(nTs/pi,fs,'LineWidth',3);
xlabel("nTs");
ylabel("f(nTs)");
title("sa(t)的欠取样信号");
% 还原
Dt = 0.005;
t = -15:Dt:15;
fa = fs*Ts*wc/pi * sinc((wc/pi)*(ones(length(nTs),1)*t-nTs'*ones(1,length(t))));
subplot(312);
plot(t,fa,'LineWidth',3);
xlabel("t");
ylabel("f(t)");
title("由欠取样信号重构sa(t)");
% 展示误差
error = abs(fa-sinc(t/pi));
subplot(313);
plot(t,error,'LineWidth',3);
xlabel("t");
ylabel("error(t)");
title("重构信号与原信号的误差error(t)");
昨天看信号突然想算算这个,结果发现不会算积分,网上学了一下,记录一下
最近通过对信号与系统的研究从信号角度进行更简单的解答
%SA:T1法利用Matlab编写主函数实现对定义域[-5,5]上的二元函数求最优解—Jason niu
[x,y] = meshgrid(-5:0.1:5,-5:0.1:5);
z = x.^2 + y.^2 - 10*cos(2*pi*x) - 10*cos(2*pi*y) + 20;
figure
mesh(x,y,z)
hold on
xlabel(‘x‘)
ylabel(‘y‘)
zlabel(‘z‘)
title(‘SA:利用SA最优化,定义域[-5,5]上的二元函数z = x^2 + y^2 - 10*cos(2*pi*x) - 10*cos(2*pi*y) + 20的最大值—Jason niu‘)
maxVal = max(z(:));
[maxIndexX,maxIndexY] = find(z == maxVal);
for i = 1:length(maxIndexX)
plot3(x(maxIndexX(i),maxIndexY(i)),y(maxIndexX(i),maxIndexY(i)), maxVal, ‘r*‘,‘linewidth‘,2)
text(x(maxIndexX(i),maxIndexY(i)),y(maxIndexX(i),maxIndexY(i)), maxVal, {[‘ X: ‘ num2str(x(maxIndexX(i),maxIndexY(i)))];[‘ Y: ‘ num2str(y(maxIndexX(i),maxIndexY(i)))];[‘ Z: ‘ num2str(maxVal)]})
hold on
end
%SA:[email protected]on_niu函数实现对二元函数优化求解—Jason niu
function fitnessVal = Jason_niu( x )