实验代码:
function y1=y1(t); y1=(t>=0);
function y2=y2(t); y2=(t>=3);
function yt=fun2(t);
yt=(2+(2*t/3)).*(y1(t)-y2(t));
h=0.001; t=-3:h:4; y=fun2(t); y3=diff(y)/h; subplot(2,1,1); plot(t,y);grid on; title('f(t)'); axis([-3,4,-0.1,4.1]); subplot(2,1,2);
plot(t(1:length(t)-1),y3); grid on; title('df(t)/dt')
图像:
3.
实验代码:
function yt1=yt1(t); yt1=(t>=-1);
function yt2=yt2(t); yt2=(t>=0);
function yt3=yt3(t); yt3=yt1(t)-yt2(t);
t=-3:0.001:3; y=yt3(t);
for x=1:length(t)
y2(x)=quad('yt3',-3,t(x)); end
subplot(2,1,1); plot(t,y);grid on; title('f(t)');
axis([-3,3,-0.01,1.01]); subplot(2,1,2) plot(t,y2);grid on; title('integral of f(t)')
图像:
f(t)10.50-3-2-10integral of f(t)1231.510.50-3-2-10123
实验二:
1.
function f1=yf1(t1); f1=2*((t1>=-1)-(t1>=2));
function f2=yf2(t2); f2=(3/4)*((t2>=0)-(t2>=3));
clc clear
dt=0.001; t1=-3:dt:3; t2=-1:dt:4; %f1=2*((t1>=-1)-(t1>=2)); %f2=(3/4)*((t2>=0)-(t2>=3)); ff1=yf1(t1); ff2=yf2(t2);
f1_conv_f2=conv(ff1,ff2); f=f1_conv_f2*dt; t=-4:0.001:7; subplot(2,2,1); plot(t1,ff1);
grid on;title('f1(t)'); axis([-3,3,-0.1,2.1]); subplot(2,2,2); plot(t2,ff2);
grid on;title('f2(t)'); axis([-1,4,-0.1,1]); subplot(2,2,3); plot(t,f);
grid on;title('f1(t)*f2(t)'); axis([-4.1,7.1,-0.1,6.1]);
图像:
f1(t)21.510.50-20210.80.60.40.20-101f2(t)234f1(t)*f2(t)20-4-20246
2.
实验代码:
function [Rxy ,tao]=my_xcorr(x,xt,y,yt,dt); ytf=fliplr(-yt); yf=fliplr(y);
x_conv_y=conv(x,yf); Rxy=x_conv_y*dt;
tao=min(xt)+min(ytf):dt:max(xt)+max(ytf); 3.
实验代码:
function [Rxy ,tao]=my_xcorr(x,xt,y,yt,dt); ytf=fliplr(-yt); yf=fliplr(y);
x_conv_y=conv(x,yf); Rxy=x_conv_y*dt;
tao=min(xt)+min(ytf):dt:max(xt)+max(ytf); clc clear
dt=0.001; xt=-2:dt:2; yt=-2:dt:2;
x=rectpuls(xt-0.5,1); y=rectpuls(yt+0.5,1);
[Rxy ,tao]=my_xcorr(x,xt,y,yt,dt); subplot(2,2,1); plot(xt,x);
grid on;title('x'); axis([-3,3,-0.1,1.5]); subplot(2,2,2); plot(yt,y);
grid on;title('y'); axis([-3,3,-0.1,1.5]); subplot(2,2,3); plot(tao,Rxy);
grid on;title('Rxy'); axis([-3,3,-0.1,1.5]);
图像:
x1.510.50-202Rxy1.510.50-2024.
实验三:
1. 验证实验原理中所述的相关程序。 Eg1:
y1.510.50-202
实验代码:
N=8;
n1=-N:-1; %计算n=-N到-1的Fourier系数
f1=-4*j*sin(n1*pi/2)/pi^2./n1.^2;%考虑到n=0时,Fn=0 f0=0; n2=1:N;
f2=-4*j*sin(n2*pi/2)/pi^2./n2.^2; Fn=[f1 f0 f2]; n=-N:N; subplot(2,2,1) stem(n,abs(Fn)); ylabel('Fn的幅度'); subplot(2,2,2) % stem(n,abs(Fn)); stem(n,imag(Fn)); title('周期三角波的频谱'); subplot(2,2,3); stem(n,angle(Fn));
ylabel('Fn的相位');xlabel('\\omega/\\omega0') 图像:
周期三角波的频谱0.80.60.5Fn的幅度0.40.20-10-505100-0.5-10-5051021Fn的相位0-1-2-10-50510/0
Eg2:
实验代码:
function SF=sig_spec(ft,t,dt,f); for m=1:length(f);
SF(m)=0;
for k=1:length(t);
SF(m)=SF(m)+ft(k).*exp(-j*2*pi*f(m)*t(k)); end
SF(m)=SF(m)*dt; end
clc,clear dt=0.001 t=-10:dt:10;
g=(t>=-0.5)-(t>=0.5); df=0.01; f=-4:df:4;
SF=sig_spec(g,t,dt,f); subplot(2,1,1),plot(t,g) axis([-1,1,-0.2,1.2]); grid on subplot(2,1,2) plot(f,SF), grid on SF_max=max(abs(SF)); title('矩形脉冲的频谱');
xlabel('f'); ylabel('F(f)'); set(gca,'xtick',[-1 0 1]);
set(gca,'ytick',[-0.5 0 0.707 1]); [x,y]=ginput(1)
line([0 x],[SF_max/sqrt(2) SF_max/sqrt(2)]); gtext('3dB带宽') line([0 1],[0 0]);
gtext('能量带宽'), grid on
图像:
10.50-1-0.8-0.6-0.4-0.200.20.40.60.81矩形脉冲的频谱10.7073dB带宽F(f)0-0.5能量带宽-10f1
Eg3:
实验代码:
function SF=sig_spec(ft,t,dt,f); for m=1:length(f); SF(m)=0;
for k=1:length(t);
SF(m)=SF(m)+ft(k).*exp(-j*2*pi*f(m)*t(k)); end
SF(m)=SF(m)*dt; end
clc,clear
Fs=1000; %调制信号x的采样频率 h=1/Fs;
Fc=400; %载波信号的载波频率小于1/2Fs t=0:h:100/Fs; f=0:0.01:600;
x=sin(2*pi*50*t); %调制信号 subplot(2,2,1); plot(t,x); xlabel('t(s)'); ylabel('x');
title('调制信号');
SF1=sig_spec(x,t,h,f) %计算调制信号的频谱 subplot(2,2,2);
plot(f,abs(SF1).^2/t(end)); %绘制调制信号的功率谱
xlabel('f(Hz)');ylabel('功率谱(X)');title('调制信号的功率谱'); grid on
%调幅时域表达式
y=x.*cos(2*pi*Fc*t); subplot(2,2,3); plot(t,y);
xlabel('t(s)');ylabel('y'); title('已调信号');
SF2=sig_spec(y,t,h,f) %计算已调信号的频谱 subplot(2,2,4);
plot(f,abs(SF2).^2/t(end)); %绘制已调信号的功率谱
xlabel('f(Hz)');ylabel('功率谱(y)');title('已调信号功率谱'); grid on
图像:
调制信号10.03调制信号的功率谱功率谱(X)00.05t(s)已调信号0.10.50-0.5-10.020.010x020040060010.50-0.5-100.05t(s)0.1820f(Hz)-3x 10已调信号的功率谱功率谱(y)y0200f(Hz)400600
2. 用手工方法求出下图周期三角脉冲信号的傅立叶系数,并用MATLAB画出其频谱。 实验代码: N=8;
n1=-N:-1; %计算n=-N到-1的Fourier系数
f1=2*(sin(n1*pi/2)).^2.*exp(-j*n1*pi)./pi^2./n1.^2; f0=0; n2=1:N;
f2=2*(sin(n2*pi/2)).^2.*exp(-j*n2*pi)./pi^2./n2.^2; Fn=[f1 f0 f2]; n=-N:N; subplot(2,2,1) stem(n,abs(Fn)); ylabel('Fn的幅度 '); subplot(2,2,2) % stem(n,abs(Fn)); stem(n,imag(Fn)); title('周期三角波的频谱');
subplot(2,2,3); stem(n,angle(Fn));
ylabel('Fn的相位');xlabel('\\omega/\\omega0')
图像:
0.40.3420-2-50510-4-10-50510x 10周期三角波的频谱-17Fn的幅度Fn的相位0.20.10-10420-2-4-10-50510
3.试用数值方法近似计算如图3-8所示门宽为2,幅度为1的三角脉冲信号的频谱
实验代码:
function SF=sig_spec(ft,t,dt,f); for m=1:length(f);
/0 SF(m)=0;
for k=1:length(t);
SF(m)=SF(m)+ft(k).*exp(-j*2*pi*f(m)*t(k)); end
SF(m)=SF(m)*dt; end
clc,clear dt=0.001 t=-10:dt:10;
ft=tripuls(t,2,0); df=0.01; f=-4:df:4; SF=sig_spec(ft,t,dt,f); subplot(2,1,1); plot(t,ft)
axis([-2.2,2.2,-0.1,1.1]); grid on
subplot(2,1,2); plot(f,SF); grid on
SF_max=max(abs(SF)); title('三角脉冲的频谱');
xlabel('f'); ylabel('F(f)'); set(gca,'xtick',[-1 0 1]);
set(gca,'ytick',[-0.5 0 0.707 1.1]); axis([-4,4,-0.5,1.1]); [x,y]=ginput(1)
line([0 x],[SF_max/sqrt(2) SF_max/sqrt(2)]); gtext('3dB带宽') grid on
图像:
10.50-2-1.5-1-0.500.511.52矩形脉冲的频谱1.10.7073dB带宽F(f)0-0.5-10f1
4.已知调制信号为ftsin100t,试分别用频率为100Hz、400Hz、800Hz的余
弦作载波信号实现三路信号的调制,并用MATLAB画出三路已调频分复用信号的时域波形和频域功率谱。
实验代码:
function SF=sig_spec(ft,t,dt,f); for m=1:length(f); SF(m)=0;
for k=1:length(t);
SF(m)=SF(m)+ft(k).*exp(-j*2*pi*f(m)*t(k)); end
SF(m)=SF(m)*dt; End
clc,clear
Fs=1000; %调制信号x的采样频率 h=1/Fs; Fc1=100; Fc2=400; Fc3=800;
t=0:h:100/Fs; f=0:0.01:600;
x=sin(2*pi*50*t); %调制信号
%调幅时域表达式 subplot(2,1,1);
y1=x.*cos(2*pi*Fc1*t); plot(t,y1,'r');
xlabel('t(s)');ylabel('时域波形'); title('已调信号'); grid on; hold on;
y2=x.*cos(2*pi*Fc2*t); plot(t,y2,'b');grid on; y3=x.*cos(2*pi*Fc3*t); plot(t,y3,'g');grid on; hold off
subplot(2,1,2);
SF1=sig_spec(y1,t,h,f) %计算已调信号的频谱
plot(f,abs(SF1).^2/t(end),'r'); %绘制已调信号的功率谱
xlabel('f(Hz)');ylabel('功率谱');title('已调信号的功率谱'); grid on; hold on;
SF2=sig_spec(y2,t,h,f) %计算已调信号的频谱
plot(f,abs(SF2).^2/t(end),'b'); %计算已调信号的频谱 grid on;
SF3=sig_spec(y3,t,h,f) %计算已调信号的频谱
plot(f,abs(SF3).^2/t(end),'g'); %计算已调信号的频谱 grid on; hold off
图像:
已调信号10.5时域波形0-0.5-10x 100.01-30.020.030.050.06t(s)已调信号的功率谱0.040.070.080.090.186功率谱4200100200300f(Hz)400500600
实验四:
1. 验证实验原理中所述的相关程序
Eg1:
function SF=sig_spec_w(ft,t,dt,f); for m=1:length(f); SF(m)=0;
for k=1:length(t);
SF(m)=SF(m)+ft(k).*exp(-j*2*pi*f(m)*t(k)); end
SF(m)=SF(m)*dt; End
clc,clear
wm=1; %信号带宽
bs=1.5; %采样角频率,欠采样
% bs=2; %2倍采样角频率,也有误差,所以一般不取奈氏频率 % bs=3; %采样角频率,大于两倍采样 ws=bs*wm;
Ts=2*pi/ws; %采样间隔
wc=1/2*ws; %理想低通截止频率 % wc=wm; %理想低通截止频率
tm=5*Ts; %使抽样点出现在nTs处 Dt=0.01; t=-tm:Dt:tm; nTs=-tm:Ts:tm; ft=sinc(t/pi); f_nTs=sinc(nTs/pi)
w_guancha=-3*ws:0.01:3*ws;
fnTs_ftf=sig_spec(f_nTs,nTs,Ts,w_guancha); %以rad/s为单位,求信号频谱 plot(w_guancha,fnTs_ftf); hold on
ft_ftf=sig_spec(ft,t,Dt,w_guancha); plot(w_guancha,ft_ftf,'r-.'); xlabel('\\omega(rad/s)');
title([num2str(bs),'倍采样信号与原信号的幅度谱']);
图像:
1.5倍采样信号与原信号的幅度谱763210-1-5-4-3-2-10(rad/s)12345
2(1)
实验代码: clc,clear
wm=1; %信号带宽
bs=1.5; %采样角频率,欠采样
% bs=2; %2倍采样角频率,也有误差,所以一般不取奈氏频率 % bs=3; %采样角频率,大于两倍采样
ws=bs*wm;
Ts=2*pi/ws; %采样间隔
wc=1/2*ws; %理想低通截止频率 % wc=wm; %理想低通截止频率
tm=5*Ts; %使抽样点出现在nTs处 Dt=0.01; t=-tm:Dt:tm; nTs=-tm:Ts:tm; ft=cos(t); f_nTs=cos(nTs)
w_guancha=-3*ws:0.01:3*ws;
fnTs_ftf=sig_spec(f_nTs,nTs,Ts,w_guancha); %以rad/s为单位,求信号频谱 plot(w_guancha,fnTs_ftf); hold on
ft_ftf=sig_spec(ft,t,Dt,w_guancha); plot(w_guancha,ft_ftf,'r-.'); xlabel('\\omega(rad/s)');
title([num2str(bs),'倍采样信号与原信号的幅度谱']);
图像:
1.5倍采样信号与原信号的幅度谱2520151050-5-10-5-4-3-2-10(rad/s)12345
3倍采样信号与原信号的幅度谱1210820-2-4-10-8-6-4-20(rad/s)246810
(2)、 实验代码: 图像:
因篇幅问题不能全部显示,请点此查看更多更全内容
Copyright © 2019- howto1234.com 版权所有 湘ICP备2023017662号-2
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务