experiment_1_1.m

来自「经典《信号与系统》教程的matlab例程,对深入理解信号与系统相关概念有很大帮助」· M 代码 · 共 53 行

M
53
字号
%==========================================================================
%  Name:experiment_1_1.m for Digital Signal Processing 
%==========================================================================
clear;close all,
p=0.0005;t1=0.5;
t=0:p:t1;
A=444.128;
a=50*1.414*pi;
omiga=1.414*50*pi;
xa=A*exp(-a*t).*sin(omiga*t).*u(t);
fs=input('Please type in the sample frequency fs=:');
T=1/fs;
L=t1/T;
n=0:L;
xn=A*exp(-a*n*T).*sin(omiga*n*T).*u(n*T);
%==========================================================================
W1=2*pi*fs;                           
N=512;           
k=-N:N;                              
W=k*W1/N;                            

Xa=xa*exp(-j*t'*W)*p;                
Xa1=abs(Xa);                          
phi=57.3*angle(Xa); 
%==========================================================================
w1=2*pi;                           
N=512;           
k=-N:N;                             
w=k*w1/N;
Xn=xn*exp(-j*(n)'*w);                  
Xn1=abs(Xn);                           
phi=57.3*angle(Xn); 
%==========================================================================
subplot(221);
plot(t,xa);grid on;
title('The curve of x(t)');
axis([0,t1,min(xn),max(xn)])
subplot(223)
stem(n,xn,'r.');grid on;
title('The curve of x(n)');
axis([0,L,min(xn),max(xn)])
xlabel('Time index n/t');
subplot(222)
plot(W/(2*pi),Xa1)
grid on;
axis([-fs,fs,0,max(Xa1)]);
title('The CTFT of xa(t)');
subplot(224)
plot(w/(2*pi),Xn1)
title('The DTFT of x(n)');
xlabel('Hz/*2pi');grid on;
axis([-1,1,0,max(Xn1)]);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?