教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 文库大全 > 专业资料 >

中南大学 信号与系统matlab实验报告(2)

来源:网络收集 时间:2026-07-09
导读: title('直流+基波') axis([-8,8,-0.5,1.5]) subplot(2,2,2) plot(t,f12),hold on y=time_fun_e(t); plot(t,y,'r:') title('1-3次谐波+直流') axis([-8,8,-0.5,1.5]) subplot(2,2,3) plot(t,f13),hold on 中南大学信

title('直流+基波') axis([-8,8,-0.5,1.5]) subplot(2,2,2) plot(t,f12),hold on y=time_fun_e(t); plot(t,y,'r:')

title('1-3次谐波+直流') axis([-8,8,-0.5,1.5]) subplot(2,2,3) plot(t,f13),hold on

中南大学信号与系统matlab的标准实验报告

y=time_fun_e(t); plot(t,y,'r:')

title('1-6次谐波+直流') axis([-8,8,-0.5,1.5]) subplot(2,2,4) plot(t,f14),hold on y=time_fun_e(t); plot(t,y,'r:')

title('1-10次谐波+直流') axis([-8,8,-0.5,1.5]) hold off end

function y=time_fun_e(t)

% 该函数是CTFShchsym.m的子函它由符号函数和表达式写成 a=1.5; T=4; h=1; tao=T/4;

t=-3*T:0.01:3*T;

e1=1/2+1/2.*sign(t-0.5+tao/2); e2=1/2+1/2.*sign(t-0.5-tao/2);

y=h.*(e1-e2); %连续时间函数-周期矩形脉冲

function x=time_fun_x(t)

% 该函数是CTFShchsym.m的子函数。它由符号变量和表达式写成。 h=1;

x1=sym('Heaviside(t)')*h; x=x1-sym('Heaviside(t-1)')*h;

中南大学信号与系统matlab的标准实验报告

源程序修改:

function [A_sym,B_sym]=CTFShchsym

% 采用符号计算求一个周期内连续时间函数f的三角级数展开系数,再用这些 % 展开系数合成连续时间函数f.傅立叶级数 % 函数的输入输出都是数值量 % Nf=6 谐波的阶数 % Nn 输出数据的准确位数

% A_sym 第1元素是直流项,其后元素依次是1,2,3...次谐波cos项展开系数 % B_sym 第2,3,4,...元素依次是1,2,3...次谐波sin项展开系数 % tao=1 tao/T=0.2 syms t n k x T=5;

tao=0.2*T; a=0.5; if nargin<4 Nf=6; end

if nargin<5 Nn=32; end

x=time_fun_x(t);

A0=int(x,t,-a,T-a)/T; %求出三角函数展开系数

中南大学信号与系统matlab的标准实验报告

A0

As=2/T*int(x*cos(2*pi*n*t/T),t,-a,T-a); %求出三角函数展开系数As Bs=2/T*int(x*sin(2*pi*n*t/T),t,-a,T-a); %求出三角函数展开系数Bs

A_sym(1)=double(vpa(A0,Nn)); %获取串数组A0所对应的ASC2码数值数组 for k=1:Nf

A_sym(k+1)=double(vpa(subs(As,n,k),Nn)); %获取串数组A所对应的ASC2码数值数组

B_sym(k+1)=double(vpa(subs(Bs,n,k),Nn)); %获取串数组B所对应的ASC2码数值数组 end if nargout==0 c=A_sym;

disp(c) %输出c为三角级数展开系数:第1元素是直流项,其后元素依次是1,2,3...次谐波cos项展开系数 d=B_sym;

disp(d) %输出d为三角级数展开系数: 第2,3,4,...元素依次是1,2,3...次谐波sin项展开系数

t=-8*a:0.01:T-a;

f0=c(1); %直流 f1=c(2).*cos(2*pi*1*t/5)+d(2).*sin(2*pi*1*t/5); % 基波

f2=c(3).*cos(2*pi*2*t/5)+d(3).*sin(2*pi*2*t/5); % 2次谐波 f3=c(4).*cos(2*pi*3*t/5)+d(4).*sin(2*pi*3*t/5); % 3次谐波 f4=c(5).*cos(2*pi*4*t/5)+d(5).*sin(2*pi*4*t/5); % 4次谐波 f5=c(6).*cos(2*pi*5*t/5)+d(6).*sin(2*pi*5*t/5); % 5次谐波 f6=c(7).*cos(2*pi*6*t/5)+d(7).*sin(2*pi*6*t/5); % 6次谐波 f7=f0+f1+f2; % 直流+基波+2次谐波

f8=f7+f3; % 直流+基波+2次谐波+3次谐波

f9=f8+f4+f6; % 直流+基波+2次谐波+3次谐波+4次谐波+6次谐波 subplot(2,2,1)

plot(t,f0+f1),hold on

y=time_fun_e(t); %调用连续时间函数-周期矩形脉冲 plot(t,y,'r:')

title('周期矩形波的形成—直流+基波') axis([-4,4.5,-0.5,1.5]) subplot(2,2,2) plot(t,f7),hold on y=time_fun_e(t); plot(t,y,'r:')

title('周期矩形波的形成—直流+基波+2次谐波') axis([-4,4.5,-0.5,1.5]) subplot(2,2,3) plot(t,f8),hold on y=time_fun_e(t);

中南大学信号与系统matlab的标准实验报告

plot(t,y,'r:')

title('直流+基波+2次谐波+3次谐波') axis([-4,4.5,-0.5,1.5]) subplot(2,2,4) plot(t,f9),hold on y=time_fun_e(t); plot(t,y,'r:')

title('基波+2次谐波+3次谐波+4次谐波+6次谐波') axis([-4,4.5,-0.5,1.5]) end

function y=time_fun_e(t)

% 该函数是CTFShchsym.m的子函它由符号函数和表达式写成 a=0.5; T=5; h=1;

tao=0.2*T;

t=-8*a:0.01:T-a;

e1=1/2+1/2.*sign(t+tao/2); e2=1/2+1/2.*sign(t-tao/2);

y=h.*(e1-e2); %连续时间函数-周期矩形脉冲

function x=time_fun_x(t)

% 该函数是CTFShchsym.m的子函数。它由符号变量和表达式写成。 h=1;

x1=sym('Heaviside(t+0.5)')*h; x=x1-sym('Heaviside(t-0.5)')*h;

2、已知周期为T=4的三角波,在第一周期(-2<t<2)内表示成:x(t) 1 t,试用MATLAB求该信号的傅立叶级数,并绘制它的频谱图。将它的频谱与方波的频谱图做比较。

function [A_sym,B_sym]=CTFSshbpsym(T,Nf)

% 采用符号计算求[0,T]内时间函数的三角级数展开系数。 % 函数的输入输出都是数值量 % Nn 输出数据的准确位数

% A_sym 第1元素是直流项,其后元素依次是1,2,3...次谐波cos项展开系数 % B_sym 第2,3,4,...元素依次是1,2,3...次谐波sin项展开系数 % T T=m*tao, 信号周期 % Nf 谐波的阶数

% m (m=T/tao)周期与脉冲宽度之比,如m=4,8,16,100等 % tao 脉宽:tao=T/m syms t n y

中南大学信号与系统matlab的标准实验报告

if nargin<3

Nf=input('please Input 所需展开的最高谐波次数:Nf='); end

T=input('please Input 信号的周期T='); if nargin<5 Nn=32; end

y=time_fun_s(t);

A0=2/T*int(y,t,0,T/2);

As=2/T*int(y*cos(2*pi*n*t/T),t,0,T/2); Bs=2/T*int(y*sin(2*pi*n*t/T),t,0,T/2); A_sym(1)=double(vpa(A0,Nn)); for k=1:Nf

A_sym(k+1)=double(vpa(subs(As,n,k),Nn)); B_sym(k+1)=double(vpa(subs(Bs,n,k),Nn)); end

if nargout==0

An=fliplr(A_sym); %对A_sym阵左右对称交换 An(1,k+1)=A_sym(1); %A_sym的1*k阵扩展为1*(k+1)阵

An=fliplr(An); %对扩展后的S1阵左右对称交换回原位置 Bn=fliplr(B_sym); %对B_sym阵左右对称交换 Bn(1,k+1)=0; %B_sym的1*k阵扩展为1*(k+1)阵

Bn=fliplr(Bn); %对扩展后的S3阵左右对称交换回原位置

FnR=An/2-i*Bn/2; % 用三角函数展开系数A、B值合成付里叶指数系数 FnL=fliplr(FnR); N=Nf*2*pi/T; k2=-N:2*pi/T:N;

Fn=[FnL,FnR(2:end)];

%subplot(3,3,3)

%x=time_fun_e(t); % 调用连续时间函数-周期矩形脉冲

subplot(2,1,1)

stem(k2,abs(Fn)); %画出周期矩形脉冲的频谱(T=M*tao) title('连续时间函数周期三角波脉冲的双边幅度谱') axis([-80,80, …… 此处隐藏:4047字,全部文档内容请下载后查看。喜欢就下载吧 ……

中南大学 信号与系统matlab实验报告(2).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wenku/52302.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)