
学习笔记之——基于matlab的数字通信系统(4)
发布日期:2021-05-10 14:16:35
浏览次数:20
分类:精选文章
本文共 1541 字,大约阅读时间需要 5 分钟。
给出sinc信号的波形(离散化)
%%%%一个离散信号,sinc(x)n=[-20:1:20];x_actual=abs(sinc(n/2));figurestem(n,x_actual);
求取一个信号x(t)在a和b区间内的傅里叶级数的系数:
function xx=fseries(funfcn,a,b,n,tol,p1,p2,p3)%FSERIES Returns the Fourier series coefficients.% XX=FSERIES(FUNFCN,A,B,N,TOL,P1,P2,P3)% funfcn=the given function, in an m-file.% It can depend on up to three parameters% p1,p2, and p3. The function is given% over one period extending from 'a' to 'b'% xx=vector of length n+1 of Fourier Series% Coefficients, xx0,xx1,...,xxn.% p1,p2,p3=parameters of funfcn. % tol=the error level.j=sqrt(-1);args0=[];for nn=1:nargin-5%%%%%%此 MATLAB 函数 针对当前正在执行的函数,返回函数调用中给定函数输入参数的数目。该语法仅可在函数体内使用。 args0=[args0,',p',int2str(nn)];endargs=[args0,')'];t=b-a;xx(1)=eval(['1/(',num2str(t),').*quad(funfcn,a,b,tol,[]',args]) for i=1:n new_fun = 'exp_fnct' ; args=[',', num2str(i), ',', num2str(t), args0, ')' ] ; xx(i+1)=eval(['1/(',num2str(t),').*quad(new_fun,a,b,tol,[],funfcn',args]);end
接下来调用这个求傅里叶级数系数的函数
% MATLAB script for Illustrative Problem 1.2.echo on;fnct='lambda';a=-4;b=4;n=24;tol=1e-6;%%%%%tol=the error level.xx=fseries(fnct,a,b,n,tol);%%%调用上面提到的傅里叶级数的函数xx1=xx(n+1:-1:2);xx1=[conj(xx1),xx];%%%%%%%conj是求复数的共轭absxx1=abs(xx1);pause % Press any key to see a plot of the magnitude spectrum.n1=[-n:n];stem(n1,absxx1)title('The Discrete Magnitude Spectrum')phasexx1=angle(xx1);%%%%%%angle()是求相位角pause % Press any key to see a plot of the phase.stem(n1,phasexx1)title('The Discrete Phase Spectrum')
按一下按键,即可弹出结果图(离散幅度谱和相位谱)
发表评论
最新留言
不错!
[***.144.177.141]2025年04月03日 11时02分57秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
Jenkins打包之本地远程自动打包教程
2021-05-11
【SQLI-Lab】靶场搭建
2021-05-11
linux环境下nginx安装
2021-05-11
mysql 分区-range分区(二)
2021-05-11
Xception 设计进化
2021-05-11
shell基础---行转列(awk),列转行(tr)
2021-05-11
抗DDOS攻击
2021-05-11
centos7安装 XtraBackup以及简单数据库备份恢复
2021-05-11
【每日一题】day09_02 数字颠倒
2021-05-11
java23种设计模式(1)-单例模式
2021-05-11
"getchar();"的作用
2021-05-11
Java容器(Map、Set、List)
2021-05-11
排序算法(一)堆排序
2021-05-11
Vue实现文本框自动获取焦点
2021-05-11
主流的基于SpringBoot的后台管理系统
2021-05-11
javaweb后台开发框架
2021-05-11
基于Laravel5.8开发的高性能后台开发框架
2021-05-11
SpringBoot+Vue+ElementUI低代码前后端分离后台管理系统
2021-05-11
基于Laravel8.x+Vue+AntDesign社会团购后台管理系统源码
2021-05-11