⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 新建 文本文档.txt

📁 信号合成
💻 TXT
字号:
T=4;tao=2;w=2*pi/T;
a0=quadl(@singrect,-2,2)/T; % 计算a0 
N=10; an=zeros(1,N); bn=zeros(1,N);
for k=1:N
an(k)=quadl(@rectcos, -2, 2, [], [], k, w)*2/T;
% 计算an. quadl中的[], []表示以默认精度进行数值积分,k,w为 
% rectcos函数中的后两个参数;
bn(k)=quadl(@rectsin, -2, 2, [], [], k, w)*2/T; %计算bn;
end;
n=1:1:N;
figure(1);
subplot(1,2,1);plot(n, an, '-o');grid on;
subplot(1,2,2);plot(n, bn, '-o');grid on;

t=-6:0.01:6;
x=pulstran(t,-8:4:8,'rectpuls',2); %生成周期矩形脉冲信号 
figure(2);subplot(6,2,1);
plot(t, x);
axis([-8,8,-1,2]); grid on;

% 有限项级数逼近 
A0=a0;
AN=sqrt(an.^2+bn.^2);
fiN=-atan(bn./an);
subplot(6,2,2); plot(t,A0/2); grid on; %直流项 
wave=a0/2;
for k=1:10
wave=wave+an(k)*cos(k*w*t+fiN(k));
subplot(6,2,k+2);plot(t,wave);grid on;
end

程序中“singrect”、“rectcos”和“rectsin”分别为所预先定义的函数文件。其中singrect.m文件为: 
function y=singrect(t);
y=(abs(t)<=1); % 定义单个矩形脉冲函数 

rectcos.m文件为: 
function y=rectcos(t, n, w);
y=(abs(t)<=1). *cos(n*w*t); % 定义了矩形脉冲与余弦函数的乘积 

rectsin.m文件为: 
function y=rectsin(t,n,w);
y=(abs(t)<=1).*sin(n*w*t); % 定义了矩形脉冲与正弦函数的乘积 

⌨️ 快捷键说明

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